From f0ad9cdf8a3ffb6616d458e84fcd4dbd2e77464c Mon Sep 17 00:00:00 2001 From: Stefan Saraev Date: Mon, 9 Dec 2013 11:21:05 +0200 Subject: [PATCH] ffmpeg: remove old patches --- ...ub-palette-as-stored-on-normal-dvd-s.patch | 56 - ...gh-logic-for-read_seek-to-be-based-o.patch | 145 - ...eturn-value-of-avio_seek-and-avoid-m.patch | 64 - .../0.10.7/ffmpeg-0.10.6-0004-asf-hacks.patch | 37 - ...t-returns-AVERROR_IO-we-are-done.-ff.patch | 27 - ...7-TV-Teletext-support-for-DVB-EBU-Te.patch | 42 - ...accept-mpegts-PMT-that-isn-t-current.patch | 41 - ...-PMT-unless-it-s-version-has-changed.patch | 43 - ...th-VDPAU-header-versions-without-MPE.patch | 63 - ...mps-as-well-as-PCR-timestamps-to-fin.patch | 100 - ...tream-durations-using-read_timestamp.patch | 69 - .../ffmpeg-0.10.6-0012-include-stdint.h.patch | 24 - ...aacenc-add-recognized-profiles-array.patch | 35 - ...second-skew-between-streams-in-mov-b.patch | 28 - ...-mpegts-demuxer-on-some-malformed-mp.patch | 38 - ...-Speed-up-mpegts-av_find_stream_info.patch | 37 - ...g-shared-library-soname-name-with-ma.patch | 43 - ...ate-slices-array-dynamically-fixes-v.patch | 75 - ...dxva-mpeg2-speed-up-slice-allocation.patch | 74 - ...-into-account-for-forward-and-backwa.patch | 49 - ...vc1-Pass-overlapping-transforms-hint.patch | 29 - ...va-playback-of-streams-that-don-t-st.patch | 75 - ...tring-td-not-supported-by-our-MingW-.patch | 26 - ...ublic-version-of-ff_read_frame_flush.patch | 48 - ...-decoding-when-display-segment-is-mi.patch | 65 - ...le-return-value-of-BeginFrame-better.patch | 51 - ...0.6-0028-added-support-for-OTF-fonts.patch | 43 - ...ill-frames-ended-up-in-internal-lavf.patch | 35 - ...-forcing-gas-preprocessor-for-darwin.patch | 14 - ...ependent-code-to-access-data-symbols.patch | 207 - ...allow-inline-asm-to-build-with-clang.patch | 56 - ...he-PTS-from-the-presentation-segment.patch | 64 - ...ac3-fix-ac3_bit_alloc_calc_bap_armv6.patch | 62 - ...034-ARM-fix-h264-chroma-mc-overrides.patch | 257 -- ...peg-fixed-missing-S_DVBSUB-subtitles.patch | 24 - ...tonic-timestamp-to-the-outside-world.patch | 337 -- ...m_fix_initialization_on_some_streams.patch | 28 - ...rced_subtitles_display_in_PGS_stream.patch | 284 -- ...fmpeg-0.10.6-905.01-VFP_acceleration.patch | 4019 ----------------- ...support-for-IPLEX-for-current-ffmpeg.patch | 1569 ------- ...discard_NAL_SEI_when_skipping_frames.patch | 13 - ...264dsp_context_in_the_parser_as_well.patch | 40 - ...ction-h264_find_start_code_canditate.patch | 129 - ...on_of-h264_find_start_code_candidate.patch | 321 -- .../0.10.7/ffmpeg-0.10.6-999.udp.patch | 122 - 45 files changed, 9008 deletions(-) delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0001-Support-raw-dvdsub-palette-as-stored-on-normal-dvd-s.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0002-Change-fallthrough-logic-for-read_seek-to-be-based-o.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0003-matroska-Check-return-value-of-avio_seek-and-avoid-m.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0004-asf-hacks.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0005-if-av_read_packet-returns-AVERROR_IO-we-are-done.-ff.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0006-added-Ticket-7187-TV-Teletext-support-for-DVB-EBU-Te.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0007-Don-t-accept-mpegts-PMT-that-isn-t-current.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0008-Don-t-reparse-PMT-unless-it-s-version-has-changed.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0009-fixed-compile-with-VDPAU-header-versions-without-MPE.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0010-Read-PID-timestamps-as-well-as-PCR-timestamps-to-fin.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0011-Get-stream-durations-using-read_timestamp.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0012-include-stdint.h.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0013-aacenc-add-recognized-profiles-array.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0014-changed-allow-4-second-skew-between-streams-in-mov-b.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0015-fixed-memleak-in-mpegts-demuxer-on-some-malformed-mp.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0016-Speed-up-mpegts-av_find_stream_info.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0017-allow-customizing-shared-library-soname-name-with-ma.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0018-dxva-mpeg2-Allocate-slices-array-dynamically-fixes-v.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0019-dxva-mpeg2-speed-up-slice-allocation.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0020-dxva-vc1-Take-BI-into-account-for-forward-and-backwa.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0021-dxva-vc1-Pass-overlapping-transforms-hint.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0022-dxva-h264-Fix-dxva-playback-of-streams-that-don-t-st.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0023-Changed-format-string-td-not-supported-by-our-MingW-.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0024-add-public-version-of-ff_read_frame_flush.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0025-dvb-subtitle-decoding-when-display-segment-is-mi.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0026-Handle-return-value-of-BeginFrame-better.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0028-added-support-for-OTF-fonts.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0028-fixed-dvd-still-frames-ended-up-in-internal-lavf.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0029-stop-forcing-gas-preprocessor-for-darwin.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0030-ARM-generate-position-independent-code-to-access-data-symbols.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0031-ARM-vp56-allow-inline-asm-to-build-with-clang.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0032-PGS-use-the-PTS-from-the-presentation-segment.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0033-ARM-ac3-fix-ac3_bit_alloc_calc_bap_armv6.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0034-ARM-fix-h264-chroma-mc-overrides.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0035-ffmpeg-fixed-missing-S_DVBSUB-subtitles.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0036-Provide-a-monotonic-timestamp-to-the-outside-world.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0037-latm_fix_initialization_on_some_streams.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0038-Fixed_forced_subtitles_display_in_PGS_stream.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-905.01-VFP_acceleration.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-912-Vividas-support-for-IPLEX-for-current-ffmpeg.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-913-h264-do_not_discard_NAL_SEI_when_skipping_frames.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.01-h264_parser-Initialize_the_h264dsp_context_in_the_parser_as_well.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.02-h264dsp-Factorize_code_into_a_new_function-h264_find_start_code_canditate.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.03-arm-Add_assembly_version_of-h264_find_start_code_candidate.patch delete mode 100644 packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-999.udp.patch diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0001-Support-raw-dvdsub-palette-as-stored-on-normal-dvd-s.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0001-Support-raw-dvdsub-palette-as-stored-on-normal-dvd-s.patch deleted file mode 100644 index 9815107f39..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0001-Support-raw-dvdsub-palette-as-stored-on-normal-dvd-s.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 5d361593f1149c2c0874d76a27c5cc68a219088c Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Sun, 11 Sep 2011 19:04:51 +0200 -Subject: [PATCH 01/24] Support raw dvdsub palette as stored on normal dvd's - -This is how the palette is stored on dvd's. Currently -only xbmc passes the palette information to libavcodec -this way. ---- - libavcodec/dvdsubdec.c | 23 +++++++++++++++++++++++ - 1 file changed, 23 insertions(+) - -diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c -index f4b5439..d0d13ee 100644 ---- a/libavcodec/dvdsubdec.c -+++ b/libavcodec/dvdsubdec.c -@@ -50,6 +50,24 @@ static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t * - } - } - -+static void ayvu_to_argb(const uint8_t *ayvu, uint32_t *argb, int num_values) -+{ -+ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; -+ uint8_t r, g, b; -+ int i, y, cb, cr, a; -+ int r_add, g_add, b_add; -+ -+ for (i = num_values; i > 0; i--) { -+ a = *ayvu++; -+ y = *ayvu++; -+ cr = *ayvu++; -+ cb = *ayvu++; -+ YUV_TO_RGB1_CCIR(cb, cr); -+ YUV_TO_RGB2_CCIR(r, g, b, y); -+ *argb++ = (a << 24) | (r << 16) | (g << 8) | b; -+ } -+} -+ - static int decode_run_2bit(GetBitContext *gb, int *color) - { - unsigned int v, t; -@@ -547,6 +565,11 @@ static int dvdsub_init(AVCodecContext *avctx) - data += strspn(data, "\n\r"); - } - -+ if (!ctx->has_palette && avctx->extradata_size == 64) { -+ ayvu_to_argb((uint8_t*)avctx->extradata, ctx->palette, 16); -+ ctx->has_palette = 1; -+ } -+ - if (ctx->has_palette) { - int i; - av_log(avctx, AV_LOG_DEBUG, "palette:"); --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0002-Change-fallthrough-logic-for-read_seek-to-be-based-o.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0002-Change-fallthrough-logic-for-read_seek-to-be-based-o.patch deleted file mode 100644 index 010fbcaa93..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0002-Change-fallthrough-logic-for-read_seek-to-be-based-o.patch +++ /dev/null @@ -1,145 +0,0 @@ -From 8b480b7321130ad691cf46314164787301691161 Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Mon, 12 Sep 2011 23:53:29 +0200 -Subject: [PATCH 02/24] Change fallthrough logic for read_seek to be based on - return value - -This changes the logic for read_seek to only use generic seek -rutines if the return value is AVERROR(ENOSYS) to avoid retrying -seeks if the demuxer already realized it wasn't possible. ---- - libavformat/asfdec.c | 2 +- - libavformat/gxf.c | 4 ++-- - libavformat/jvdec.c | 2 +- - libavformat/matroskadec.c | 2 +- - libavformat/oggdec.c | 4 +++- - libavformat/pmpdec.c | 2 +- - libavformat/r3d.c | 2 +- - libavformat/utils.c | 4 +++- - 8 files changed, 13 insertions(+), 9 deletions(-) - -diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c -index 0deafc6..a62bab3 100644 ---- a/libavformat/asfdec.c -+++ b/libavformat/asfdec.c -@@ -1278,7 +1278,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int - AVStream *st = s->streams[stream_index]; - - if (s->packet_size <= 0) -- return -1; -+ return AVERROR(ENOSYS); - - /* Try using the protocol's read_seek if available */ - if(s->pb) { -diff --git a/libavformat/gxf.c b/libavformat/gxf.c -index e773ba7..a3298a7 100644 ---- a/libavformat/gxf.c -+++ b/libavformat/gxf.c -@@ -542,7 +542,7 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int - idx = av_index_search_timestamp(st, timestamp - start_time, - AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD); - if (idx < 0) -- return -1; -+ return AVERROR(ENOSYS); - pos = st->index_entries[idx].pos; - if (idx < st->nb_index_entries - 2) - maxlen = st->index_entries[idx + 2].pos - pos; -@@ -552,7 +552,7 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int - return res; - found = gxf_resync_media(s, maxlen, -1, timestamp); - if (FFABS(found - timestamp) > 4) -- return -1; -+ return AVERROR(ENOSYS); - return 0; - } - -diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c -index 212cd8a..d52060b 100644 ---- a/libavformat/jvdec.c -+++ b/libavformat/jvdec.c -@@ -207,7 +207,7 @@ static int read_seek(AVFormatContext *s, int stream_index, - } - - if (i < 0 || i >= ast->nb_index_entries) -- return 0; -+ return -1; - if (avio_seek(s->pb, ast->index_entries[i].pos, SEEK_SET) < 0) - return -1; - -diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c -index 2787a17..135fddd 100644 ---- a/libavformat/matroskadec.c -+++ b/libavformat/matroskadec.c -@@ -2048,7 +2048,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, - } - - if (!st->nb_index_entries) -- return 0; -+ return -1; - timestamp = FFMAX(timestamp, st->index_entries[0].timestamp); - - if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) { -diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c -index ceb4091..80669a5 100644 ---- a/libavformat/oggdec.c -+++ b/libavformat/oggdec.c -@@ -663,8 +663,10 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index, - - ret = ff_seek_frame_binary(s, stream_index, timestamp, flags); - os = ogg->streams + stream_index; -- if (ret < 0) -+ if (ret < 0) { - os->keyframe_seek = 0; -+ ret = AVERROR(ENOSYS); -+ } - return ret; - } - -diff --git a/libavformat/pmpdec.c b/libavformat/pmpdec.c -index a57b660..9db4e26 100644 ---- a/libavformat/pmpdec.c -+++ b/libavformat/pmpdec.c -@@ -157,7 +157,7 @@ static int pmp_seek(AVFormatContext *s, int stream_index, int64_t ts, int flags) - PMPContext *pmp = s->priv_data; - pmp->cur_stream = 0; - // fallback to default seek now -- return -1; -+ return AVERROR(ENOSYS); - } - - static int pmp_close(AVFormatContext *s) -diff --git a/libavformat/r3d.c b/libavformat/r3d.c -index 874c361..0adad72 100644 ---- a/libavformat/r3d.c -+++ b/libavformat/r3d.c -@@ -358,7 +358,7 @@ static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, i - int frame_num; - - if (!st->codec->time_base.num || !st->time_base.den) -- return -1; -+ return AVERROR(ENOSYS); - - frame_num = sample_time*st->codec->time_base.den/ - ((int64_t)st->codec->time_base.num*st->time_base.den); -diff --git a/libavformat/utils.c b/libavformat/utils.c -index 9164cd0..242d616 100644 ---- a/libavformat/utils.c -+++ b/libavformat/utils.c -@@ -1910,11 +1910,13 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f - ff_read_frame_flush(s); - ret = s->iformat->read_seek(s, stream_index, timestamp, flags); - } else -- ret = -1; -+ ret = AVERROR(ENOSYS); - ) - if (ret >= 0) { - return 0; - } -+ if (ret != AVERROR(ENOSYS)) -+ return ret; - - if (s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) { - ff_read_frame_flush(s); --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0003-matroska-Check-return-value-of-avio_seek-and-avoid-m.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0003-matroska-Check-return-value-of-avio_seek-and-avoid-m.patch deleted file mode 100644 index fe9ca1cf81..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0003-matroska-Check-return-value-of-avio_seek-and-avoid-m.patch +++ /dev/null @@ -1,64 +0,0 @@ -From a8a72d52860df38f3a126ca544663f9ea379a929 Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Sat, 22 Oct 2011 18:33:45 +0200 -Subject: [PATCH 03/24] [matroska] Check return value of avio_seek and avoid - modifying state if it fails - -The code still modifies state if the timestamp is not found. Not -sure exactly how to avoid that. ---- - libavformat/matroskadec.c | 19 ++++++++++++------- - 1 file changed, 12 insertions(+), 7 deletions(-) - -diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c -index 135fddd..a9a0d1f 100644 ---- a/libavformat/matroskadec.c -+++ b/libavformat/matroskadec.c -@@ -2052,7 +2052,8 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, - timestamp = FFMAX(timestamp, st->index_entries[0].timestamp); - - if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) { -- avio_seek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET); -+ if (avio_seek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET) < 0) -+ return -1; - matroska->current_id = 0; - while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) { - matroska_clear_queue(matroska); -@@ -2061,16 +2062,11 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, - } - } - -- matroska_clear_queue(matroska); - if (index < 0) - return 0; - - index_min = index; - for (i=0; i < matroska->tracks.nb_elem; i++) { -- tracks[i].audio.pkt_cnt = 0; -- tracks[i].audio.sub_packet_cnt = 0; -- tracks[i].audio.buf_timecode = AV_NOPTS_VALUE; -- tracks[i].end_timecode = 0; - if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE - && !tracks[i].stream->discard != AVDISCARD_ALL) { - index_sub = av_index_search_timestamp(tracks[i].stream, st->index_entries[index].timestamp, AVSEEK_FLAG_BACKWARD); -@@ -2081,7 +2077,16 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, - } - } - -- avio_seek(s->pb, st->index_entries[index_min].pos, SEEK_SET); -+ if (avio_seek(s->pb, st->index_entries[index_min].pos, SEEK_SET) < 0) -+ return -1; -+ -+ matroska_clear_queue(matroska); -+ for (i=0; i < matroska->tracks.nb_elem; i++) { -+ tracks[i].audio.pkt_cnt = 0; -+ tracks[i].audio.sub_packet_cnt = 0; -+ tracks[i].audio.buf_timecode = AV_NOPTS_VALUE; -+ tracks[i].end_timecode = 0; -+ } - matroska->current_id = 0; - matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY); - matroska->skip_to_timecode = st->index_entries[index].timestamp; --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0004-asf-hacks.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0004-asf-hacks.patch deleted file mode 100644 index 70c2d28f3a..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0004-asf-hacks.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 16ed0150800958b4ca544fd380bda92f21393555 Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Mon, 12 Sep 2011 21:37:17 +0200 -Subject: [PATCH 04/24] asf hacks - ---- - libavformat/asfdec.c | 11 +++++++++++ - 1 file changed, 11 insertions(+) - -diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c -index a62bab3..7db3bd8 100644 ---- a/libavformat/asfdec.c -+++ b/libavformat/asfdec.c -@@ -1277,9 +1277,20 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int - ASFContext *asf = s->priv_data; - AVStream *st = s->streams[stream_index]; - -+ if (pts == 0) { -+ // this is a hack since av_gen_search searches the entire file in this case -+ av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", s->data_offset); -+ if (avio_seek(s->pb, s->data_offset, SEEK_SET) < 0) -+ return -1; -+ return 0; -+ } -+ - if (s->packet_size <= 0) - return AVERROR(ENOSYS); - -+ if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO) -+ return -1; -+ - /* Try using the protocol's read_seek if available */ - if(s->pb) { - int ret = avio_seek_time(s->pb, stream_index, pts, flags); --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0005-if-av_read_packet-returns-AVERROR_IO-we-are-done.-ff.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0005-if-av_read_packet-returns-AVERROR_IO-we-are-done.-ff.patch deleted file mode 100644 index 93371335f6..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0005-if-av_read_packet-returns-AVERROR_IO-we-are-done.-ff.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 55467e617c4772441e128cfcc3939beafdd8bf8a Mon Sep 17 00:00:00 2001 -From: Cory Fields -Date: Mon, 28 Jun 2010 01:55:31 -0400 -Subject: [PATCH 05/24] if av_read_packet returns AVERROR_IO, we are done. - ffmpeg's codecs might or might not handle returning - any completed demuxed packets correctly - ---- - libavformat/utils.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/libavformat/utils.c b/libavformat/utils.c -index 242d616..ebb8493 100644 ---- a/libavformat/utils.c -+++ b/libavformat/utils.c -@@ -1248,6 +1248,8 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) - if (ret < 0) { - if (ret == AVERROR(EAGAIN)) - return ret; -+ if (ret == AVERROR(EIO)) -+ return ret; - /* return the last frames, if any */ - for(i = 0; i < s->nb_streams; i++) { - st = s->streams[i]; --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0006-added-Ticket-7187-TV-Teletext-support-for-DVB-EBU-Te.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0006-added-Ticket-7187-TV-Teletext-support-for-DVB-EBU-Te.patch deleted file mode 100644 index fa32988546..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0006-added-Ticket-7187-TV-Teletext-support-for-DVB-EBU-Te.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 406e25be924a32d5df14a977e8b9694a767f6378 Mon Sep 17 00:00:00 2001 -From: Cory Fields -Date: Mon, 28 Jun 2010 02:10:50 -0400 -Subject: [PATCH 06/24] added: Ticket #7187, TV Teletext support for DVB EBU - Teletext streams - ---- - libavcodec/avcodec.h | 4 ++++ - libavformat/mpegts.c | 2 ++ - 2 files changed, 6 insertions(+) - -diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h -index 81849c1..0b756d0 100644 ---- a/libavcodec/avcodec.h -+++ b/libavcodec/avcodec.h -@@ -425,6 +425,10 @@ enum CodecID { - CODEC_ID_SRT, - CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'), - -+ /* data codecs */ -+ CODEC_ID_VBI_DATA= 0x17500, -+ CODEC_ID_VBI_TELETEXT, -+ - /* other specific kind of codecs (generally used for attachments) */ - CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. - CODEC_ID_TTF = 0x18000, -diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c -index 9998248..e7e061e 100644 ---- a/libavformat/mpegts.c -+++ b/libavformat/mpegts.c -@@ -581,6 +581,8 @@ static const StreamType DESC_types[] = { - { 0x7b, AVMEDIA_TYPE_AUDIO, CODEC_ID_DTS }, - { 0x56, AVMEDIA_TYPE_SUBTITLE, CODEC_ID_DVB_TELETEXT }, - { 0x59, AVMEDIA_TYPE_SUBTITLE, CODEC_ID_DVB_SUBTITLE }, /* subtitling descriptor */ -+ { 0x45, AVMEDIA_TYPE_DATA, CODEC_ID_VBI_DATA }, /* VBI Data descriptor */ -+ { 0x46, AVMEDIA_TYPE_DATA, CODEC_ID_VBI_TELETEXT }, /* VBI Teletext descriptor */ - { 0 }, - }; - --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0007-Don-t-accept-mpegts-PMT-that-isn-t-current.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0007-Don-t-accept-mpegts-PMT-that-isn-t-current.patch deleted file mode 100644 index e2c0cc40e7..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0007-Don-t-accept-mpegts-PMT-that-isn-t-current.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 3bf21b1049abf8991beac79235adfcca9d705eda Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Sun, 18 Sep 2011 19:16:34 +0200 -Subject: [PATCH 07/24] Don't accept mpegts PMT that isn't current - ---- - libavformat/mpegts.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c -index e7e061e..817fbed 100644 ---- a/libavformat/mpegts.c -+++ b/libavformat/mpegts.c -@@ -437,6 +437,7 @@ typedef struct SectionHeader { - uint8_t tid; - uint16_t id; - uint8_t version; -+ uint8_t current; - uint8_t sec_num; - uint8_t last_sec_num; - } SectionHeader; -@@ -508,6 +509,7 @@ static int parse_section_header(SectionHeader *h, - val = get8(pp, p_end); - if (val < 0) - return -1; -+ h->current = val & 0x1; - h->version = (val >> 1) & 0x1f; - val = get8(pp, p_end); - if (val < 0) -@@ -1556,6 +1558,8 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len - return; - if (h->tid != PAT_TID) - return; -+ if (!h->current) -+ return; - - ts->stream->ts_id = h->id; - --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0008-Don-t-reparse-PMT-unless-it-s-version-has-changed.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0008-Don-t-reparse-PMT-unless-it-s-version-has-changed.patch deleted file mode 100644 index e22b8a1582..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0008-Don-t-reparse-PMT-unless-it-s-version-has-changed.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 5fecd135de1486be63e0cef53134c44f8b4becd6 Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Sun, 18 Sep 2011 19:17:23 +0200 -Subject: [PATCH 08/24] Don't reparse PMT unless it's version has changed - ---- - libavformat/mpegts.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c -index 817fbed..8bdafc5 100644 ---- a/libavformat/mpegts.c -+++ b/libavformat/mpegts.c -@@ -78,6 +78,7 @@ struct MpegTSFilter { - int pid; - int es_id; - int last_cc; /* last cc code (-1 if first packet) */ -+ int last_version; /* last version of data on this pid */ - enum MpegTSFilterType type; - union { - MpegTSPESFilter pes_filter; -@@ -334,6 +335,7 @@ static MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int - filter->pid = pid; - filter->es_id = -1; - filter->last_cc = -1; -+ filter->last_version = -1; - sec = &filter->u.section_filter; - sec->section_cb = section_cb; - sec->opaque = opaque; -@@ -1560,6 +1562,10 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len - return; - if (!h->current) - return; -+ if (h->version == filter->last_version) -+ return; -+ filter->last_version = h->version; -+ av_dlog(ts->stream, "version=%d\n", filter->last_version); - - ts->stream->ts_id = h->id; - --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0009-fixed-compile-with-VDPAU-header-versions-without-MPE.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0009-fixed-compile-with-VDPAU-header-versions-without-MPE.patch deleted file mode 100644 index 7c86e01163..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0009-fixed-compile-with-VDPAU-header-versions-without-MPE.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 13fa8f2299e51192354cfb468dc05452ab9c9e4e Mon Sep 17 00:00:00 2001 -From: Cory Fields -Date: Mon, 28 Jun 2010 03:04:26 -0400 -Subject: [PATCH 09/24] fixed: compile with VDPAU header versions without - MPEG4 support. - -See http://repo.or.cz/w/FFMpeg-mirror/mplayer-patches.git/commitdiff/136c16af11076153717d3de31c9d84360644e006 ---- - configure | 2 ++ - libavcodec/vdpau.c | 2 ++ - libavcodec/vdpau.h | 2 ++ - 3 files changed, 6 insertions(+) - -diff --git a/configure b/configure -index 07d473e..6255f57 100755 ---- a/configure -+++ b/configure -@@ -3058,6 +3058,8 @@ check_header sys/select.h - check_header termios.h - check_header vdpau/vdpau.h - check_header vdpau/vdpau_x11.h -+check_cpp_condition vdpau/vdpau.h "defined(VDP_DECODER_PROFILE_MPEG4_PART2_SP)" && enable vdpau_mpeg4_support -+ - check_header X11/extensions/XvMClib.h - check_header asm/types.h - -diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c -index ce5103a..21b4fc9 100644 ---- a/libavcodec/vdpau.c -+++ b/libavcodec/vdpau.c -@@ -316,6 +316,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, - render->bitstream_buffers_used = 0; - } - -+#ifdef VDP_DECODER_PROFILE_MPEG4_PART2_SP - void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, - int buf_size) - { -@@ -369,6 +370,7 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, - ff_draw_horiz_band(s, 0, s->avctx->height); - render->bitstream_buffers_used = 0; - } -+#endif - - // Only dummy functions for now - static int vdpau_mpeg2_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) -diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h -index f3a5471..3748675 100644 ---- a/libavcodec/vdpau.h -+++ b/libavcodec/vdpau.h -@@ -79,7 +79,9 @@ struct vdpau_render_state { - VdpPictureInfoH264 h264; - VdpPictureInfoMPEG1Or2 mpeg; - VdpPictureInfoVC1 vc1; -+#ifdef VDP_DECODER_PROFILE_MPEG4_PART2_SP - VdpPictureInfoMPEG4Part2 mpeg4; -+#endif - } info; - }; - --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0010-Read-PID-timestamps-as-well-as-PCR-timestamps-to-fin.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0010-Read-PID-timestamps-as-well-as-PCR-timestamps-to-fin.patch deleted file mode 100644 index c2a836886c..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0010-Read-PID-timestamps-as-well-as-PCR-timestamps-to-fin.patch +++ /dev/null @@ -1,100 +0,0 @@ -From 17c6bca0f47b1a0c3deac3ad948cdd674c135321 Mon Sep 17 00:00:00 2001 -From: Cory Fields -Date: Fri, 9 Jul 2010 16:43:31 -0400 -Subject: [PATCH 10/24] Read PID timestamps as well as PCR timestamps to find - location in mpegts stream - ---- - libavformat/mpegts.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 46 insertions(+), 2 deletions(-) - -diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c -index 8bdafc5..ba2f163 100644 ---- a/libavformat/mpegts.c -+++ b/libavformat/mpegts.c -@@ -1928,6 +1928,44 @@ static int parse_pcr(int64_t *ppcr_high, int *ppcr_low, - return 0; - } - -+static int parse_timestamp(int64_t *ts, const uint8_t *buf) -+{ -+ int afc, flags; -+ const uint8_t *p; -+ -+ if(!(buf[1] & 0x40)) /* must be a start packet */ -+ return -1; -+ -+ afc = (buf[3] >> 4) & 3; -+ p = buf + 4; -+ if (afc == 0 || afc == 2) /* invalid or only adaption field */ -+ return -1; -+ if (afc == 3) -+ p += p[0] + 1; -+ if (p >= buf + TS_PACKET_SIZE) -+ return -1; -+ -+ if (p[0] != 0x00 || p[1] != 0x00 || p[2] != 0x01) /* packet_start_code_prefix */ -+ return -1; -+ -+ flags = p[3] | 0x100; /* stream type */ -+ if (!((flags >= 0x1c0 && flags <= 0x1df) || -+ (flags >= 0x1e0 && flags <= 0x1ef) || -+ (flags == 0x1bd) || (flags == 0x1fd))) -+ return -1; -+ -+ flags = p[7]; -+ if ((flags & 0xc0) == 0x80) { -+ *ts = ff_parse_pes_pts(p+9); -+ return 0; -+ } else if ((flags & 0xc0) == 0xc0) { -+ *ts = ff_parse_pes_pts(p+9+5); -+ return 0; -+ } -+ return -1; -+} -+ -+ - static int mpegts_read_header(AVFormatContext *s, - AVFormatParameters *ap) - { -@@ -2118,6 +2156,7 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, - int64_t pos, timestamp; - uint8_t buf[TS_PACKET_SIZE]; - int pcr_l, pcr_pid = ((PESContext*)s->streams[stream_index]->priv_data)->pcr_pid; -+ int pid = ((PESContext*)s->streams[stream_index]->priv_data)->pid; - pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47; - while(pos < pos_limit) { - if (avio_seek(s->pb, pos, SEEK_SET) < 0) -@@ -2135,6 +2174,11 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, - *ppos = pos; - return timestamp; - } -+ if ((pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pid) && -+ parse_timestamp(×tamp, buf) == 0) { -+ *ppos = pos; -+ return timestamp; -+ } - pos += ts->raw_packet_size; - } - -@@ -2322,7 +2366,7 @@ AVInputFormat ff_mpegts_demuxer = { - .read_header = mpegts_read_header, - .read_packet = mpegts_read_packet, - .read_close = mpegts_read_close, -- .read_timestamp = mpegts_get_dts, -+ .read_timestamp = mpegts_get_pcr, - .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT, - #ifdef USE_SYNCPOINT_SEARCH - .read_seek2 = read_seek2, -@@ -2336,7 +2380,7 @@ AVInputFormat ff_mpegtsraw_demuxer = { - .read_header = mpegts_read_header, - .read_packet = mpegts_raw_read_packet, - .read_close = mpegts_read_close, -- .read_timestamp = mpegts_get_dts, -+ .read_timestamp = mpegts_get_pcr, - .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT, - #ifdef USE_SYNCPOINT_SEARCH - .read_seek2 = read_seek2, --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0011-Get-stream-durations-using-read_timestamp.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0011-Get-stream-durations-using-read_timestamp.patch deleted file mode 100644 index 60f097ed19..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0011-Get-stream-durations-using-read_timestamp.patch +++ /dev/null @@ -1,69 +0,0 @@ -From 95926a84fe1369f796c916f72c50dd5b7d50b15a Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Sat, 22 Oct 2011 19:01:38 +0200 -Subject: [PATCH 11/24] Get stream durations using read_timestamp - ---- - libavformat/utils.c | 39 +++++++++++++++++++++++++++++++++++++++ - 1 file changed, 39 insertions(+) - -diff --git a/libavformat/utils.c b/libavformat/utils.c -index ebb8493..25fe38e 100644 ---- a/libavformat/utils.c -+++ b/libavformat/utils.c -@@ -2082,6 +2082,41 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic) - #define DURATION_MAX_READ_SIZE 250000 - #define DURATION_MAX_RETRY 3 - -+static void av_estimate_timings_from_pts2(AVFormatContext *ic, int64_t old_offset) -+{ -+ AVStream *st; -+ int i, step= 1024; -+ int64_t ts, pos; -+ -+ for(i=0;inb_streams;i++) { -+ st = ic->streams[i]; -+ -+ pos = 0; -+ ts = ic->iformat->read_timestamp(ic, i, &pos, DURATION_MAX_READ_SIZE); -+ if (ts == AV_NOPTS_VALUE) -+ continue; -+ if (st->start_time > ts || st->start_time == AV_NOPTS_VALUE) -+ st->start_time = ts; -+ -+ pos = url_fsize(ic->pb) - 1; -+ do { -+ pos -= step; -+ ts = ic->iformat->read_timestamp(ic, i, &pos, pos + step); -+ step += step; -+ } while (ts == AV_NOPTS_VALUE && pos >= step && step < DURATION_MAX_READ_SIZE); -+ -+ if (ts == AV_NOPTS_VALUE) -+ continue; -+ -+ if (st->duration < ts - st->start_time || st->duration == AV_NOPTS_VALUE) -+ st->duration = ts - st->start_time; -+ } -+ -+ fill_all_stream_timings(ic); -+ -+ avio_seek(ic->pb, old_offset, SEEK_SET); -+} -+ - /* only usable for MPEG-PS streams */ - static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) - { -@@ -2184,6 +2219,10 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset) - /* at least one component has timings - we use them for all - the components */ - fill_all_stream_timings(ic); -+ } else if (ic->iformat->read_timestamp && -+ file_size && ic->pb->seekable) { -+ /* get accurate estimate from the PTSes */ -+ av_estimate_timings_from_pts2(ic, old_offset); - } else { - av_log(ic, AV_LOG_WARNING, "Estimating duration from bitrate, this may be inaccurate\n"); - /* less precise: use bitrate info */ --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0012-include-stdint.h.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0012-include-stdint.h.patch deleted file mode 100644 index f81c35a443..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0012-include-stdint.h.patch +++ /dev/null @@ -1,24 +0,0 @@ -From eaa6256c161f1f6d48b222b171f68869dace8f3f Mon Sep 17 00:00:00 2001 -From: Cory Fields -Date: Fri, 9 Jul 2010 16:49:01 -0400 -Subject: [PATCH 12/24] include stdint.h - ---- - libavutil/common.h | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/libavutil/common.h b/libavutil/common.h -index 84290c6..5b73579 100644 ---- a/libavutil/common.h -+++ b/libavutil/common.h -@@ -29,6 +29,7 @@ - #include - #include - #include -+#include - #include - #include - #include --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0013-aacenc-add-recognized-profiles-array.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0013-aacenc-add-recognized-profiles-array.patch deleted file mode 100644 index 8e3b847106..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0013-aacenc-add-recognized-profiles-array.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 8728e8bdef30313f1961d2687cfb0ffccf540797 Mon Sep 17 00:00:00 2001 -From: Anssi Hannula -Date: Fri, 21 Jan 2011 20:44:02 +0200 -Subject: [PATCH 13/24] aacenc: add recognized profiles array - -Submitted upstream. ---- - libavcodec/aacenc.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c -index 2ff6f9c..4ffaa3d 100644 ---- a/libavcodec/aacenc.c -+++ b/libavcodec/aacenc.c -@@ -777,6 +777,11 @@ static const AVClass aacenc_class = { - LIBAVUTIL_VERSION_INT, - }; - -+static const AVProfile profiles[] = { -+ { FF_PROFILE_AAC_LOW, "Low" }, -+ { FF_PROFILE_UNKNOWN }, -+}; -+ - AVCodec ff_aac_encoder = { - .name = "aac", - .type = AVMEDIA_TYPE_AUDIO, -@@ -789,4 +794,5 @@ AVCodec ff_aac_encoder = { - .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, - .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"), - .priv_class = &aacenc_class, -+ .profiles = profiles, - }; --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0014-changed-allow-4-second-skew-between-streams-in-mov-b.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0014-changed-allow-4-second-skew-between-streams-in-mov-b.patch deleted file mode 100644 index be05ec0824..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0014-changed-allow-4-second-skew-between-streams-in-mov-b.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 5cc735503bfe1242606f19638bffeb686dd4d1b5 Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Wed, 8 Dec 2010 14:03:43 +0000 -Subject: [PATCH 14/24] changed: allow 4 second skew between streams in mov - before attempting to seek - ---- - libavformat/mov.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/libavformat/mov.c b/libavformat/mov.c -index 9da8eab..0f9836c 100644 ---- a/libavformat/mov.c -+++ b/libavformat/mov.c -@@ -2763,8 +2763,8 @@ static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st) - if (!sample || (!s->pb->seekable && current_sample->pos < sample->pos) || - (s->pb->seekable && - ((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb && -- ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) || -- (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) { -+ ((FFABS(best_dts - dts) <= 4*AV_TIME_BASE && current_sample->pos < sample->pos) || -+ (FFABS(best_dts - dts) > 4*AV_TIME_BASE && dts < best_dts)))))) { - sample = current_sample; - best_dts = dts; - *st = avst; --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0015-fixed-memleak-in-mpegts-demuxer-on-some-malformed-mp.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0015-fixed-memleak-in-mpegts-demuxer-on-some-malformed-mp.patch deleted file mode 100644 index f930be4599..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0015-fixed-memleak-in-mpegts-demuxer-on-some-malformed-mp.patch +++ /dev/null @@ -1,38 +0,0 @@ -From b83c9a2505338cdf021dd499c26686e82bcbc066 Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Fri, 26 Nov 2010 20:56:48 +0000 -Subject: [PATCH 15/24] fixed: memleak in mpegts demuxer on some malformed - (??) mpegts files with too large pes packets - -at-visions sample file brokenStream.mpg ---- - libavformat/mpegts.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c -index ba2f163..c374cb9 100644 ---- a/libavformat/mpegts.c -+++ b/libavformat/mpegts.c -@@ -664,6 +664,10 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, - - static void new_pes_packet(PESContext *pes, AVPacket *pkt) - { -+ if(pkt->data) { -+ av_log(pes->stream, AV_LOG_ERROR, "ignoring previously allocated packet on stream %d\n", pkt->stream_index); -+ av_free_packet(pkt); -+ } - av_init_packet(pkt); - - pkt->destruct = av_destruct_packet; -@@ -2117,6 +2121,8 @@ static int mpegts_read_packet(AVFormatContext *s, - int ret, i; - - ts->pkt = pkt; -+ ts->pkt->data = NULL; -+ - ret = handle_packets(ts, 0); - if (ret < 0) { - /* flush pes data left */ --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0016-Speed-up-mpegts-av_find_stream_info.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0016-Speed-up-mpegts-av_find_stream_info.patch deleted file mode 100644 index a1af1bd744..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0016-Speed-up-mpegts-av_find_stream_info.patch +++ /dev/null @@ -1,37 +0,0 @@ -From c240357f903f20ba51001fb90aa2de415d5be825 Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Mon, 28 Jun 2010 21:26:54 +0000 -Subject: [PATCH 16/24] Speed up mpegts av_find_stream_info - ---- - libavformat/mpegts.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c -index c374cb9..6da6db5 100644 ---- a/libavformat/mpegts.c -+++ b/libavformat/mpegts.c -@@ -825,7 +825,7 @@ static int mpegts_push_data(MpegTSFilter *filter, - goto skip; - - /* stream not present in PMT */ -- if (!pes->st) { -+ if (ts->auto_guess && !pes->st) { - pes->st = avformat_new_stream(ts->stream, NULL); - if (!pes->st) - return AVERROR(ENOMEM); -@@ -2013,7 +2013,10 @@ static int mpegts_read_header(AVFormatContext *s, - - av_dlog(ts->stream, "tuning done\n"); - -- s->ctx_flags |= AVFMTCTX_NOHEADER; -+ /* only flag NOHEADER if we are in file mode, -+ in streaming mode scanning may take too long for users */ -+ if (!url_is_streamed(pb)) -+ s->ctx_flags |= AVFMTCTX_NOHEADER; - } else { - AVStream *st; - int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l; --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0017-allow-customizing-shared-library-soname-name-with-ma.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0017-allow-customizing-shared-library-soname-name-with-ma.patch deleted file mode 100644 index 8ca10d4393..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0017-allow-customizing-shared-library-soname-name-with-ma.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 954d92f3fc2c5bd45fc1b4d347f2d9295d269574 Mon Sep 17 00:00:00 2001 -From: Anssi Hannula -Date: Wed, 23 Feb 2011 19:24:07 +0200 -Subject: [PATCH 17/24] allow customizing shared library soname (name with - major) - -This is a hack. ---- - configure | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/configure b/configure -index 6255f57..5e11b2d 100755 ---- a/configure -+++ b/configure -@@ -238,6 +238,7 @@ Advanced options (experts only): - --arch=ARCH select architecture [$arch] - --cpu=CPU select the minimum required CPU (affects - instruction selection, may crash on older CPUs) -+ --custom-libname-with-major=NAME custom library name with major [$SLIBNAME_WITH_MAJOR] - --disable-asm disable all assembler optimizations - --disable-altivec disable AltiVec optimizations - --disable-amd3dnow disable 3DNow! optimizations -@@ -1298,6 +1299,7 @@ CMDLINE_SET=" - cpu - cross_prefix - cxx -+ custom_libname_with_major - dep_cc - extra_version - host_cc -@@ -2778,6 +2780,8 @@ EOF - exit 1; - fi - -+test -n "$custom_libname_with_major" && SLIBNAME_WITH_MAJOR="$custom_libname_with_major" -+ - die_license_disabled() { - enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; } - } --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0018-dxva-mpeg2-Allocate-slices-array-dynamically-fixes-v.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0018-dxva-mpeg2-Allocate-slices-array-dynamically-fixes-v.patch deleted file mode 100644 index 87e31c5b70..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0018-dxva-mpeg2-Allocate-slices-array-dynamically-fixes-v.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 40f4c15370f7027dc5422edcb10e8a3b7e58e83d Mon Sep 17 00:00:00 2001 -From: CrystalP -Date: Wed, 5 Oct 2011 12:38:30 -0400 -Subject: [PATCH 18/24] dxva-mpeg2 Allocate slices array dynamically - fixes - videos with > 175 slices. They used to result in - images with a black bottom. - -sample on team ftp samples/PR471/too_many_slices.ts - -Inspired by the vaapi code to reallocate the slices array for each new slice. -Could be more efficient if the array could be preserved for all frames and -freed only at the end of the video, but there doesn't seem to be anywhere -appropriate to free the memory at the end. - -Alternative is to allocate the proper size straight away for a new frame, -instead of realloc'ing for each slice. ---- - libavcodec/dxva2_mpeg2.c | 14 +++++++++++--- - 1 file changed, 11 insertions(+), 3 deletions(-) - -diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c -index 951305d..8ba83b6 100644 ---- a/libavcodec/dxva2_mpeg2.c -+++ b/libavcodec/dxva2_mpeg2.c -@@ -22,12 +22,12 @@ - - #include "dxva2_internal.h" - --#define MAX_SLICES (SLICE_MAX_START_CODE - SLICE_MIN_START_CODE + 1) - struct dxva2_picture_context { - DXVA_PictureParameters pp; - DXVA_QmatrixData qm; - unsigned slice_count; -- DXVA_SliceInfo slice[MAX_SLICES]; -+ DXVA_SliceInfo *slice; -+ unsigned int slice_alloc; - - const uint8_t *bitstream; - unsigned bitstream_size; -@@ -220,6 +220,8 @@ static int start_frame(AVCodecContext *avctx, - fill_quantization_matrices(avctx, ctx, s, &ctx_pic->qm); - - ctx_pic->slice_count = 0; -+ ctx_pic->slice = NULL; -+ ctx_pic->slice_alloc = 0; - ctx_pic->bitstream_size = 0; - ctx_pic->bitstream = NULL; - return 0; -@@ -232,9 +234,14 @@ static int decode_slice(AVCodecContext *avctx, - struct dxva2_picture_context *ctx_pic = - s->current_picture_ptr->f.hwaccel_picture_private; - unsigned position; -+ DXVA_SliceInfo* slice; - -- if (ctx_pic->slice_count >= MAX_SLICES) -+ slice = av_fast_realloc(ctx_pic->slice, -+ &ctx_pic->slice_alloc, -+ (ctx_pic->slice_count + 1) * sizeof(DXVA_SliceInfo)); -+ if (!slice) - return -1; -+ ctx_pic->slice = slice; - - if (!ctx_pic->bitstream) - ctx_pic->bitstream = buffer; -@@ -258,6 +265,7 @@ static int end_frame(AVCodecContext *avctx) - &ctx_pic->pp, sizeof(ctx_pic->pp), - &ctx_pic->qm, sizeof(ctx_pic->qm), - commit_bitstream_and_slice_buffer); -+ av_freep(ctx_pic->slice); - } - - AVHWAccel ff_mpeg2_dxva2_hwaccel = { --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0019-dxva-mpeg2-speed-up-slice-allocation.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0019-dxva-mpeg2-speed-up-slice-allocation.patch deleted file mode 100644 index 9bb1a9a812..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0019-dxva-mpeg2-speed-up-slice-allocation.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 681f74b224e16a4df7f8c4e31a9be56975d57e10 Mon Sep 17 00:00:00 2001 -From: CrystalP -Date: Mon, 10 Oct 2011 19:42:50 -0400 -Subject: [PATCH 19/24] dxva-mpeg2 speed up slice allocation - -The number of slices is not very likely to change from frame to frame, so -at the beginning of a new frame, allocate memory for the amount of slices of -the previous frame. Saves a lot of reallocation, for some TV capture samples -there are over 200 slices. - -There wasn't anywhere really appropriate to store last_slice_count (needs to -live from first frame to last frame), so this is likely to cause discussion to -merge upstream. -Adding members to dxva_context breaks ABI, which we don't care too much about -since on Windows we don't support external ffmpeg. -dxva mpeg2 code also has access to MpegEncContext, but adding there would -likely break ABI as well. ---- - libavcodec/dxva2.h | 1 + - libavcodec/dxva2_mpeg2.c | 12 ++++++++++++ - 2 files changed, 13 insertions(+) - -diff --git a/libavcodec/dxva2.h b/libavcodec/dxva2.h -index fc99560..16a6994 100644 ---- a/libavcodec/dxva2.h -+++ b/libavcodec/dxva2.h -@@ -66,6 +66,7 @@ struct dxva_context { - * Private to the FFmpeg AVHWAccel implementation - */ - unsigned report_id; -+ unsigned last_slice_count; - }; - - #endif /* AVCODEC_DXVA_H */ -diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c -index 8ba83b6..90507f9 100644 ---- a/libavcodec/dxva2_mpeg2.c -+++ b/libavcodec/dxva2_mpeg2.c -@@ -224,6 +224,16 @@ static int start_frame(AVCodecContext *avctx, - ctx_pic->slice_alloc = 0; - ctx_pic->bitstream_size = 0; - ctx_pic->bitstream = NULL; -+ -+ if (ctx->last_slice_count > 0) -+ { -+ ctx_pic->slice = av_fast_realloc(NULL, -+ &ctx_pic->slice_alloc, -+ ctx->last_slice_count * sizeof(DXVA_SliceInfo)); -+ if (!ctx_pic->slice) -+ return -1; -+ } -+ - return 0; - } - -@@ -258,6 +268,7 @@ static int end_frame(AVCodecContext *avctx) - struct MpegEncContext *s = avctx->priv_data; - struct dxva2_picture_context *ctx_pic = - s->current_picture_ptr->f.hwaccel_picture_private; -+ struct dxva_context *ctx = avctx->hwaccel_context; - - if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) - return -1; -@@ -266,6 +277,7 @@ static int end_frame(AVCodecContext *avctx) - &ctx_pic->qm, sizeof(ctx_pic->qm), - commit_bitstream_and_slice_buffer); - av_freep(ctx_pic->slice); -+ ctx->last_slice_count = ctx_pic->slice_count; - } - - AVHWAccel ff_mpeg2_dxva2_hwaccel = { --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0020-dxva-vc1-Take-BI-into-account-for-forward-and-backwa.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0020-dxva-vc1-Take-BI-into-account-for-forward-and-backwa.patch deleted file mode 100644 index faf10c744a..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0020-dxva-vc1-Take-BI-into-account-for-forward-and-backwa.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 1c0fcc2cfe27197368e0490afe34dd51a831995f Mon Sep 17 00:00:00 2001 -From: CrystalP -Date: Wed, 5 Oct 2011 12:53:38 -0400 -Subject: [PATCH 20/24] dxva-vc1 Take BI into account for forward and backward - pictures - -See ticket #11643, sample on team ftp, samples/11643/vc-1 test.wmv ---- - libavcodec/dxva2_vc1.c | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c -index 0ae9685..23507d3 100644 ---- a/libavcodec/dxva2_vc1.c -+++ b/libavcodec/dxva2_vc1.c -@@ -38,15 +38,17 @@ static void fill_picture_parameters(AVCodecContext *avctx, - { - const MpegEncContext *s = &v->s; - const Picture *current_picture = s->current_picture_ptr; -+ BYTE bPicIntra = s->pict_type == AV_PICTURE_TYPE_I || v->bi_type == 1; -+ BYTE bPicBackwardPrediction = s->pict_type == AV_PICTURE_TYPE_B && v->bi_type == 0; - - memset(pp, 0, sizeof(*pp)); - pp->wDecodedPictureIndex = - pp->wDeblockedPictureIndex = ff_dxva2_get_surface_index(ctx, current_picture); -- if (s->pict_type != AV_PICTURE_TYPE_I) -+ if (!bPicIntra) - pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->last_picture); - else - pp->wForwardRefPictureIndex = 0xffff; -- if (s->pict_type == AV_PICTURE_TYPE_B) -+ if (bPicBackwardPrediction) - pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture); - else - pp->wBackwardRefPictureIndex = 0xffff; -@@ -69,8 +71,8 @@ static void fill_picture_parameters(AVCodecContext *avctx, - if (s->picture_structure & PICT_BOTTOM_FIELD) - pp->bPicStructure |= 0x02; - pp->bSecondField = v->interlace && v->fcm != ILACE_FIELD && !s->first_field; -- pp->bPicIntra = s->pict_type == AV_PICTURE_TYPE_I; -- pp->bPicBackwardPrediction = s->pict_type == AV_PICTURE_TYPE_B; -+ pp->bPicIntra = bPicIntra; -+ pp->bPicBackwardPrediction = bPicBackwardPrediction; - pp->bBidirectionalAveragingMode = (1 << 7) | - ((ctx->cfg->ConfigIntraResidUnsigned != 0) << 6) | - ((ctx->cfg->ConfigResidDiffAccelerator != 0) << 5) | --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0021-dxva-vc1-Pass-overlapping-transforms-hint.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0021-dxva-vc1-Pass-overlapping-transforms-hint.patch deleted file mode 100644 index c108abca60..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0021-dxva-vc1-Pass-overlapping-transforms-hint.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 6ba7fd3e2acf39e8c276e7db901c54dba0fd8307 Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Sat, 22 Oct 2011 21:59:22 +0200 -Subject: [PATCH 21/24] dxva-vc1 Pass overlapping transforms hint - -see ticket #11643 ---- - libavcodec/dxva2_vc1.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c -index 23507d3..9d550dd 100644 ---- a/libavcodec/dxva2_vc1.c -+++ b/libavcodec/dxva2_vc1.c -@@ -103,7 +103,10 @@ static void fill_picture_parameters(AVCodecContext *avctx, - (v->rangered << 3) | - (s->max_b_frames ); - pp->bPicExtrapolation = (!v->interlace || v->fcm == PROGRESSIVE) ? 1 : 2; -- pp->bPicDeblocked = ((v->profile != PROFILE_ADVANCED && v->rangeredfrm) << 5) | -+ pp->bPicDeblocked = ((v->overlap == 1 && -+ pp->bPicBackwardPrediction == 0 && -+ ctx->cfg->ConfigResidDiffHost == 0) << 6) | -+ ((v->profile != PROFILE_ADVANCED && v->rangeredfrm) << 5) | - (s->loop_filter << 1); - pp->bPicDeblockConfined = (v->postprocflag << 7) | - (v->broadcast << 6) | --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0022-dxva-h264-Fix-dxva-playback-of-streams-that-don-t-st.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0022-dxva-h264-Fix-dxva-playback-of-streams-that-don-t-st.patch deleted file mode 100644 index e56f8ee216..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0022-dxva-h264-Fix-dxva-playback-of-streams-that-don-t-st.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 3b6417ff1e86c2aa72fc5360f67be2db8b83b80d Mon Sep 17 00:00:00 2001 -From: CrystalP -Date: Wed, 5 Oct 2011 13:13:25 -0400 -Subject: [PATCH 22/24] dxva-h264 Fix dxva playback of streams that don't - start with an I-Frame. - -GPUs with ATI UVDa and UVD+ have trouble when decoding doesn't start on an -I-Frame, and they don't recover on later I-Frames. - -The variable to track the first I-Frame is in H264Context so that it can be -reset by code in h264 when initializing the context or flushing. - -credits isidrogar, see ticket #11772. -sample on team ftp, samples/11772/CSI_ New York - TV3 - 2008-09-16_1.ts ---- - libavcodec/dxva2_h264.c | 8 ++++++++ - libavcodec/h264.c | 2 ++ - libavcodec/h264.h | 2 ++ - 3 files changed, 12 insertions(+) - -diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c -index af91e02..b7e0251 100644 ---- a/libavcodec/dxva2_h264.c -+++ b/libavcodec/dxva2_h264.c -@@ -432,6 +432,14 @@ static int end_frame(AVCodecContext *avctx) - - if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) - return -1; -+ -+ // Wait for an I-frame before start decoding. Workaround for ATI UVD and UVD+ GPUs -+ if (!h->got_first_iframe) { -+ if (!(ctx_pic->pp.wBitFields & (1 << 15))) -+ return -1; -+ h->got_first_iframe = 1; -+ } -+ - return ff_dxva2_common_end_frame(avctx, s, - &ctx_pic->pp, sizeof(ctx_pic->pp), - &ctx_pic->qm, sizeof(ctx_pic->qm), -diff --git a/libavcodec/h264.c b/libavcodec/h264.c -index d010b55..98c7a5d 100644 ---- a/libavcodec/h264.c -+++ b/libavcodec/h264.c -@@ -2372,6 +2372,7 @@ static void flush_dpb(AVCodecContext *avctx){ - h->delayed_pic[i]->f.reference = 0; - h->delayed_pic[i]= NULL; - } -+ h->got_first_iframe = 0; - h->outputed_poc=h->next_outputed_poc= INT_MIN; - h->prev_interlaced_frame = 1; - idr(h); -@@ -2819,6 +2820,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ - } - s->first_field = 0; - h->prev_interlaced_frame = 1; -+ h->got_first_iframe = 0; - - init_scan_tables(h); - if (ff_h264_alloc_tables(h) < 0) { -diff --git a/libavcodec/h264.h b/libavcodec/h264.h -index d0dfca3..f4df997 100644 ---- a/libavcodec/h264.h -+++ b/libavcodec/h264.h -@@ -584,6 +584,8 @@ typedef struct H264Context{ - int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag - int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag - -+ int got_first_iframe; -+ - // Timestamp stuff - int sei_buffering_period_present; ///< Buffering period SEI flag - int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0023-Changed-format-string-td-not-supported-by-our-MingW-.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0023-Changed-format-string-td-not-supported-by-our-MingW-.patch deleted file mode 100644 index 04c19f6f74..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0023-Changed-format-string-td-not-supported-by-our-MingW-.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0b24d2cd7338ddba22926a7725dc751cc801ac78 Mon Sep 17 00:00:00 2001 -From: Joakim Plate -Date: Sat, 22 Oct 2011 22:01:31 +0200 -Subject: [PATCH 23/24] Changed format string - %td not supported by our MingW - environment. - ---- - libavcodec/h264.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libavcodec/h264.c b/libavcodec/h264.c -index 98c7a5d..c4785db 100644 ---- a/libavcodec/h264.c -+++ b/libavcodec/h264.c -@@ -3629,7 +3629,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){ - return 0; - } - if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 2) { -- av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d, bytestream (%td)\n", s->mb_x, s->mb_y, h->cabac.bytestream_end - h->cabac.bytestream); -+ av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d, bytestream (%d)\n", s->mb_x, s->mb_y, h->cabac.bytestream_end - h->cabac.bytestream); - ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR&part_mask); - return -1; - } --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0024-add-public-version-of-ff_read_frame_flush.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0024-add-public-version-of-ff_read_frame_flush.patch deleted file mode 100644 index f6c5c3bab7..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0024-add-public-version-of-ff_read_frame_flush.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 399301fd74ed748d24d7ee2806f50e8ad57aeea8 Mon Sep 17 00:00:00 2001 -From: elupus -Date: Tue, 1 Nov 2011 20:18:35 +0100 -Subject: [PATCH 24/24] add public version of ff_read_frame_flush - -We need this since we sometimes seek on the -input stream behind ffmpeg's back. After this -all data need to be flushed completely. ---- - libavformat/avformat.h | 5 +++++ - libavformat/utils.c | 5 +++++ - 2 files changed, 10 insertions(+) - -diff --git a/libavformat/avformat.h b/libavformat/avformat.h -index 1e8a629..c76ac71 100644 ---- a/libavformat/avformat.h -+++ b/libavformat/avformat.h -@@ -1631,6 +1631,11 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt); - int av_read_frame(AVFormatContext *s, AVPacket *pkt); - - /** -+ * Clear out any buffered data in context -+ */ -+void av_read_frame_flush(AVFormatContext *s); -+ -+/** - * Seek to the keyframe at timestamp. - * 'timestamp' in 'stream_index'. - * @param stream_index If stream_index is (-1), a default -diff --git a/libavformat/utils.c b/libavformat/utils.c -index 25fe38e..4729a40 100644 ---- a/libavformat/utils.c -+++ b/libavformat/utils.c -@@ -1463,6 +1463,11 @@ void ff_read_frame_flush(AVFormatContext *s) - } - } - -+void av_read_frame_flush(AVFormatContext *s) -+{ -+ ff_read_frame_flush(s); -+} -+ - #if FF_API_SEEK_PUBLIC - void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp) - { --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0025-dvb-subtitle-decoding-when-display-segment-is-mi.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0025-dvb-subtitle-decoding-when-display-segment-is-mi.patch deleted file mode 100644 index d7c035016b..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0025-dvb-subtitle-decoding-when-display-segment-is-mi.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 6261cbcd71e5cd192623434fa698e9f1e701f365 Mon Sep 17 00:00:00 2001 -From: Paul Kendall -Date: Sun, 29 Jan 2012 14:50:19 +0100 -Subject: [PATCH 1/1] Fix dvb subtitle decoding when display segment is - missing. - -closes ticket #8504 ---- - libavcodec/dvbsubdec.c | 11 +++++++++++ - 1 file changed, 11 insertions(+) - -diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c -index e2a804a..503223f 100644 ---- a/libavcodec/dvbsubdec.c -+++ b/libavcodec/dvbsubdec.c -@@ -1451,6 +1451,7 @@ static int dvbsub_decode(AVCodecContext *avctx, - int segment_type; - int page_id; - int segment_length; -+ int got_segment = 0; - int i; - - av_dlog(avctx, "DVB sub packet:\n"); -@@ -1490,21 +1491,26 @@ static int dvbsub_decode(AVCodecContext *avctx, - switch (segment_type) { - case DVBSUB_PAGE_SEGMENT: - dvbsub_parse_page_segment(avctx, p, segment_length); -+ got_segment |= 1; - break; - case DVBSUB_REGION_SEGMENT: - dvbsub_parse_region_segment(avctx, p, segment_length); -+ got_segment |= 2; - break; - case DVBSUB_CLUT_SEGMENT: - dvbsub_parse_clut_segment(avctx, p, segment_length); -+ got_segment |= 4; - break; - case DVBSUB_OBJECT_SEGMENT: - dvbsub_parse_object_segment(avctx, p, segment_length); -+ got_segment |= 8; - break; - case DVBSUB_DISPLAYDEFINITION_SEGMENT: - dvbsub_parse_display_definition_segment(avctx, p, segment_length); - break; - case DVBSUB_DISPLAY_SEGMENT: - *data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub); -+ got_segment |= 16; - break; - default: - av_dlog(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n", -@@ -1516,6 +1522,11 @@ static int dvbsub_decode(AVCodecContext *avctx, - p += segment_length; - } - -+ // Some streams do not send a display segment but if we have all the other -+ // segments then we need no further data. -+ if (got_segment == 15 && sub) -+ *data_size = dvbsub_display_end_segment(avctx, p, 0, sub); -+ - return p - buf; - } - --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0026-Handle-return-value-of-BeginFrame-better.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0026-Handle-return-value-of-BeginFrame-better.patch deleted file mode 100644 index b7051c0128..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0026-Handle-return-value-of-BeginFrame-better.patch +++ /dev/null @@ -1,51 +0,0 @@ -From d659958d58dfec08f4666a8add325c8154a662de Mon Sep 17 00:00:00 2001 -From: CrystalP -Date: Fri, 11 Nov 2011 19:10:54 -0500 -Subject: [PATCH 1/1] Handle return value of BeginFrame better. - -The nVidia cards sometimes return E_PENDING and need time before they can start -decoding a new frame. - -Helps nVidia cards with blocky pictures/pixellation artifacts after skip or -when CPU is busy. ---- - libavcodec/dxva2.c | 14 ++++++++++++-- - 1 file changed, 12 insertions(+), 2 deletions(-) - -diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c -index b6f8aea..3a10f69 100644 ---- a/libavcodec/dxva2.c -+++ b/libavcodec/dxva2.c -@@ -21,6 +21,9 @@ - */ - - #include "dxva2_internal.h" -+#include -+ -+#define MAX_RETRY_ON_PENDING 50 - - void *ff_dxva2_get_surface(const Picture *picture) - { -@@ -88,10 +91,17 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, MpegEncContext *s, - DXVA2_DecodeBufferDesc buffer[4]; - DXVA2_DecodeExecuteParams exec; - int result; -+ HRESULT hr; -+ int tries = 0; - -- if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder, -+ while ((hr=IDirectXVideoDecoder_BeginFrame(ctx->decoder, - ff_dxva2_get_surface(s->current_picture_ptr), -- NULL))) { -+ NULL)) == E_PENDING -+ && tries < MAX_RETRY_ON_PENDING) { -+ usleep(1000); -+ tries++; -+ } -+ if (FAILED(hr)) { - av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n"); - return -1; - } --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0028-added-support-for-OTF-fonts.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0028-added-support-for-OTF-fonts.patch deleted file mode 100644 index 97f7094276..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0028-added-support-for-OTF-fonts.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 864acb01cc73762918794ddecf0fc2f7b6cf8529 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=A9bastien=20Brochet?= -Date: Sun, 15 Apr 2012 22:43:46 +0200 -Subject: [PATCH 1/3] added: support for OTF fonts -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - - -Signed-off-by: Sébastien Brochet ---- - libavcodec/avcodec.h | 1 + - libavformat/matroska.c | 1 + - 2 files changed, 2 insertions(+), 0 deletion(-) - -diff --git a/lib/ffmpeg/libavcodec/avcodec.h b/lib/ffmpeg/libavcodec/avcodec.h -index 0b756d0..6996c92 100644 ---- a/libavcodec/avcodec.h -+++ b/libavcodec/avcodec.h -@@ -435,6 +435,7 @@ enum CodecID { - CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'), - CODEC_ID_XBIN = MKBETAG('X','B','I','N'), - CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'), -+ CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'), - - CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it - -diff --git a/lib/ffmpeg/libavformat/matroska.c b/lib/ffmpeg/libavformat/matroska.c -index 52481d7..2f5b617 100644 ---- a/libavformat/matroska.c -+++ b/libavformat/matroska.c -@@ -90,6 +90,7 @@ const CodecMime ff_mkv_mime_tags[] = { - {"image/tiff" , CODEC_ID_TIFF}, - {"application/x-truetype-font", CODEC_ID_TTF}, - {"application/x-font" , CODEC_ID_TTF}, -+ {"application/vnd.ms-opentype", CODEC_ID_OTF}, - - {"" , CODEC_ID_NONE} - }; -index 17cbd48..4524141 100644 --- -1.7.10.msysgit.1 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0028-fixed-dvd-still-frames-ended-up-in-internal-lavf.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0028-fixed-dvd-still-frames-ended-up-in-internal-lavf.patch deleted file mode 100644 index db2b39a5ed..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0028-fixed-dvd-still-frames-ended-up-in-internal-lavf.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 90a3ab0d766e3a026a37f7290f59abda30c4de32 Mon Sep 17 00:00:00 2001 -From: elupus -Date: Tue, 17 Apr 2012 01:13:15 +0200 -Subject: [PATCH] fixed: dvd still frames ended up in internal lavf buffer - -This is very hackish, but it's the old solution we had for dvd -still frames. The problem is that the demuxer asks for probing -of the codec in the mpeg stream. This causes lavf to read the -whole menu structure into internal buffers. After which, it -won't read from input stream anymore and no events triggers. - -The only proper fix to avoid this is to allow this situation -in our navigator. This needs further work so that we can -process HOP/ACTIVATION events in libdvdnav without advancing -stream. ---- - libavformat/utils.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libavformat/utils.c b/libavformat/utils.c -index 1bf81a5..051dcc0 100644 ---- a/libavformat/utils.c -+++ b/libavformat/utils.c -@@ -833,7 +833,7 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt) - - if(end || av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){ - int score= set_codec_from_probe_data(s, st, pd); -- if( (st->codec->codec_id != CODEC_ID_NONE && score > AVPROBE_SCORE_MAX/4) -+ if( (st->codec->codec_id != CODEC_ID_NONE && score > AVPROBE_SCORE_MAX/4-1) - || end){ - pd->buf_size=0; - av_freep(&pd->buf); --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0029-stop-forcing-gas-preprocessor-for-darwin.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0029-stop-forcing-gas-preprocessor-for-darwin.patch deleted file mode 100644 index fb3b558fbc..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0029-stop-forcing-gas-preprocessor-for-darwin.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/configure b/configure -index 5e11b2d..c06005b 100755 ---- a/configure -+++ b/configure -@@ -2635,7 +2635,7 @@ case $target_os in - ;; - darwin) - enable malloc_aligned -- gas="gas-preprocessor.pl $cc" -+ #gas="gas-preprocessor.pl $cc" - enabled ppc && add_asflags -force_cpusubtype_ALL - SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)' - enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0030-ARM-generate-position-independent-code-to-access-data-symbols.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0030-ARM-generate-position-independent-code-to-access-data-symbols.patch deleted file mode 100644 index b31f59b481..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0030-ARM-generate-position-independent-code-to-access-data-symbols.patch +++ /dev/null @@ -1,207 +0,0 @@ -From 2ac4f22e8cea4489431cf879edba31124f19c3ba Mon Sep 17 00:00:00 2001 -From: Memphiz -Date: Fri, 29 Jun 2012 19:41:48 +0200 -Subject: [PATCH] [ffmpeg] - ARM: generate position independent code to access - data symbols - this finally fixes our ATV2 builds. I send - more then a really big THX to M.Rullgard from libav for - making this happen. - ---- - lib/ffmpeg/libavcodec/arm/ac3dsp_armv6.S | 4 +- - lib/ffmpeg/libavcodec/arm/asm.S | 73 +++++++++++++++++++++++++++- - lib/ffmpeg/libavcodec/arm/fft_fixed_neon.S | 2 +- - lib/ffmpeg/libavcodec/arm/fft_neon.S | 4 +- - lib/ffmpeg/libavcodec/arm/vp3dsp_neon.S | 3 +- - lib/ffmpeg/libavcodec/arm/vp8_armv6.S | 4 +- - 6 files changed, 80 insertions(+), 10 deletions(-) - -diff --git a/libavcodec/arm/ac3dsp_armv6.S b/libavcodec/arm/ac3dsp_armv6.S -index b6aee86..97099d6 100644 ---- a/libavcodec/arm/ac3dsp_armv6.S -+++ b/libavcodec/arm/ac3dsp_armv6.S -@@ -26,8 +26,8 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1 - beq 4f - push {r4-r11,lr} - add r5, sp, #40 -- movrel r4, X(ff_ac3_bin_to_band_tab) -- movrel lr, X(ff_ac3_band_start_tab) -+ movrelx r4, X(ff_ac3_bin_to_band_tab), r11 -+ movrelx lr, X(ff_ac3_band_start_tab) - ldm r5, {r5-r7} - ldrb r4, [r4, r2] - add r1, r1, r2, lsl #1 @ psd + start -diff --git a/libavcodec/arm/asm.S b/libavcodec/arm/asm.S -index e540eac..d34a16d 100644 ---- a/libavcodec/arm/asm.S -+++ b/libavcodec/arm/asm.S -@@ -62,7 +62,14 @@ ELF .eabi_attribute 25, \val - .endm - - .macro function name, export=0 -+ .set .Lpic_idx, 0 -+ .set .Lpic_gp, 0 - .macro endfunc -+ .if .Lpic_idx -+ .altmacro -+ put_pic %(.Lpic_idx - 1) -+ .noaltmacro -+ .endif - ELF .size \name, . - \name - .endfunc - .purgem endfunc -@@ -99,8 +106,44 @@ ELF .size \name, . - \name - #endif - .endm - -+.macro put_pic num -+ put_pic_\num -+.endm -+ -+.macro do_def_pic num, val, label -+ .macro put_pic_\num -+ .if \num -+ .altmacro -+ put_pic %(\num - 1) -+ .noaltmacro -+ .endif -+\label: .word \val -+ .purgem put_pic_\num -+ .endm -+.endm -+ -+.macro def_pic val, label -+ .altmacro -+ do_def_pic %.Lpic_idx, \val, \label -+ .noaltmacro -+ .set .Lpic_idx, .Lpic_idx + 1 -+.endm -+ -+.macro ldpic rd, val, indir=0 -+ ldr \rd, .Lpicoff\@ -+.Lpic\@: -+ .if \indir -+ ldr \rd, [pc, \rd] -+ .else -+ add \rd, pc, \rd -+ .endif -+ def_pic \val - (.Lpic\@ + (8 >> CONFIG_THUMB)), .Lpicoff\@ -+.endm -+ - .macro movrel rd, val --#if HAVE_ARMV6T2 && !CONFIG_PIC && !defined(__APPLE__) -+#if CONFIG_PIC -+ ldpic \rd, \val -+#elif HAVE_ARMV6T2 && !defined(__APPLE__) - movw \rd, #:lower16:\val - movt \rd, #:upper16:\val - #else -@@ -108,6 +151,34 @@ ELF .size \name, . - \name - #endif - .endm - -+.macro movrelx rd, val, gp -+#if CONFIG_PIC && defined(__ELF__) -+ .ifnb \gp -+ .if .Lpic_gp -+ .unreq gp -+ .endif -+ gp .req \gp -+ ldpic gp, _GLOBAL_OFFSET_TABLE_ -+ .elseif !.Lpic_gp -+ gp .req r12 -+ ldpic gp, _GLOBAL_OFFSET_TABLE_ -+ .endif -+ .set .Lpic_gp, 1 -+ ldr \rd, .Lpicoff\@ -+ ldr \rd, [gp, \rd] -+ def_pic \val(GOT), .Lpicoff\@ -+#elif CONFIG_PIC && defined(__APPLE__) -+ ldpic \rd, .Lpic\@, indir=1 -+ .non_lazy_symbol_pointer -+.Lpic\@: -+ .indirect_symbol \val -+ .word 0 -+ .text -+#else -+ movrel \rd, \val -+#endif -+.endm -+ - .macro ldr_pre rt, rn, rm:vararg - A ldr \rt, [\rn, \rm]! - T add \rn, \rn, \rm -diff --git a/libavcodec/arm/fft_fixed_neon.S b/libavcodec/arm/fft_fixed_neon.S -index 0316b80..d6b7dac 100644 ---- a/libavcodec/arm/fft_fixed_neon.S -+++ b/libavcodec/arm/fft_fixed_neon.S -@@ -214,7 +214,7 @@ function fft\n\()_neon - bl fft\n4\()_neon - mov r0, r4 - pop {r4, lr} -- movrel r1, X(ff_cos_\n\()_fixed) -+ movrelx r1, X(ff_cos_\n\()_fixed) - mov r2, #\n4/2 - b fft_pass_neon - endfunc -diff --git a/libavcodec/arm/fft_neon.S b/libavcodec/arm/fft_neon.S -index ef8e4d4..d36927b 100644 ---- a/libavcodec/arm/fft_neon.S -+++ b/libavcodec/arm/fft_neon.S -@@ -143,7 +143,7 @@ function fft16_neon - vswp d29, d30 @ q14{r12,i12,i14,r15} q15{r13,i13,i15,r14} - vadd.f32 q0, q12, q13 @ {t1,t2,t5,t6} - vadd.f32 q1, q14, q15 @ {t1a,t2a,t5a,t6a} -- movrel r2, X(ff_cos_16) -+ movrelx r2, X(ff_cos_16) - vsub.f32 q13, q12, q13 @ {t3,t4,t7,t8} - vrev64.32 d1, d1 - vsub.f32 q15, q14, q15 @ {t3a,t4a,t7a,t8a} -@@ -290,7 +290,7 @@ function fft\n\()_neon - bl fft\n4\()_neon - mov r0, r4 - pop {r4, lr} -- movrel r1, X(ff_cos_\n) -+ movrelx r1, X(ff_cos_\n) - mov r2, #\n4/2 - b fft_pass_neon - endfunc -diff --git a/libavcodec/arm/vp3dsp_neon.S b/libavcodec/arm/vp3dsp_neon.S -index ae3e402..90d9f80 100644 ---- a/libavcodec/arm/vp3dsp_neon.S -+++ b/libavcodec/arm/vp3dsp_neon.S -@@ -116,9 +116,8 @@ function vp3_idct_start_neon - vadd.s16 q1, q8, q12 - vsub.s16 q8, q8, q12 - vld1.64 {d28-d31}, [r2,:128]! --endfunc - --function vp3_idct_core_neon -+vp3_idct_core_neon: - vmull.s16 q2, d18, xC1S7 // (ip[1] * C1) << 16 - vmull.s16 q3, d19, xC1S7 - vmull.s16 q4, d2, xC4S4 // ((ip[0] + ip[4]) * C4) << 16 -diff --git a/libavcodec/arm/vp8_armv6.S b/libavcodec/arm/vp8_armv6.S -index 8a3beb9..adb49f7 100644 ---- a/libavcodec/arm/vp8_armv6.S -+++ b/libavcodec/arm/vp8_armv6.S -@@ -65,7 +65,7 @@ T orrcs \cw, \cw, \t1 - - function ff_decode_block_coeffs_armv6, export=1 - push {r0,r1,r4-r11,lr} -- movrel lr, X(ff_vp56_norm_shift) -+ movrelx lr, X(ff_vp56_norm_shift) - ldrd r4, r5, [sp, #44] @ token_prob, qmul - cmp r3, #0 - ldr r11, [r5] -@@ -206,7 +206,7 @@ A orrcs r8, r8, r10, lsl r6 - mov r9, #8 - it ge - addge r12, r12, #1 -- movrel r4, X(ff_vp8_dct_cat_prob) -+ movrelx r4, X(ff_vp8_dct_cat_prob), r1 - lsl r9, r9, r12 - ldr r4, [r4, r12, lsl #2] - add r12, r9, #3 --- -1.7.9.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0031-ARM-vp56-allow-inline-asm-to-build-with-clang.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0031-ARM-vp56-allow-inline-asm-to-build-with-clang.patch deleted file mode 100644 index 994be915e2..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0031-ARM-vp56-allow-inline-asm-to-build-with-clang.patch +++ /dev/null @@ -1,56 +0,0 @@ -#The clang integrated assembler does not support pre-UAL syntax, -#while gcc requires pre-UAL syntax for ARM code. A patch[1] for -#clang to support the old syntax as well has been ignored since -#January. -# -#This patch chooses the syntax appropriate for each compiler, -#allowing both to build the code. Notably, this change allows -#building for iphone with the latest Apple Xcode update. -# -#[1] http://llvm.org/bugs/show_bug.cgi?id=11855 -# -#Signed-off-by: Mans Rullgard - -diff --git a/libavcodec/arm/vp56_arith.h b/libavcodec/arm/vp56_arith.h -index ef30ffe..d1a8837 100644 ---- a/libavcodec/arm/vp56_arith.h -+++ b/libavcodec/arm/vp56_arith.h -@@ -29,6 +29,14 @@ - # define T(x) - #endif - -+#if CONFIG_THUMB || defined __clang__ -+# define L(x) -+# define U(x) x -+#else -+# define L(x) x -+# define U(x) -+#endif -+ - #if HAVE_ARMV6 && HAVE_INLINE_ASM - - #define vp56_rac_get_prob vp56_rac_get_prob_armv6 -@@ -42,8 +50,8 @@ static inline int vp56_rac_get_prob_armv6(VP56RangeCoder *c, int pr) - __asm__ ("adds %3, %3, %0 \n" - "itt cs \n" - "cmpcs %7, %4 \n" -- A("ldrcsh %2, [%4], #2 \n") -- T("ldrhcs %2, [%4], #2 \n") -+ L("ldrcsh %2, [%4], #2 \n") -+ U("ldrhcs %2, [%4], #2 \n") - "rsb %0, %6, #256 \n" - "smlabb %0, %5, %6, %0 \n" - T("itttt cs \n") -@@ -80,8 +88,8 @@ static inline int vp56_rac_get_prob_branchy_armv6(VP56RangeCoder *c, int pr) - __asm__ ("adds %3, %3, %0 \n" - "itt cs \n" - "cmpcs %7, %4 \n" -- A("ldrcsh %2, [%4], #2 \n") -- T("ldrhcs %2, [%4], #2 \n") -+ L("ldrcsh %2, [%4], #2 \n") -+ U("ldrhcs %2, [%4], #2 \n") - "rsb %0, %6, #256 \n" - "smlabb %0, %5, %6, %0 \n" - T("itttt cs \n") --- -1.7.11.1 diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0032-PGS-use-the-PTS-from-the-presentation-segment.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0032-PGS-use-the-PTS-from-the-presentation-segment.patch deleted file mode 100644 index 8b773e6253..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0032-PGS-use-the-PTS-from-the-presentation-segment.patch +++ /dev/null @@ -1,64 +0,0 @@ -diff --git a/lib/ffmpeg/libavcodec/pgssubdec.c b/lib/ffmpeg/libavcodec/pgssubdec.c -index 2785d25..02e650a 100644 ---- a/libavcodec/pgssubdec.c -+++ b/libavcodec/pgssubdec.c -@@ -64,6 +64,7 @@ typedef struct PGSSubContext { - PGSSubPresentation presentation; - uint32_t clut[256]; - PGSSubPicture pictures[UINT16_MAX]; -+ int64_t pts; - } PGSSubContext; - - static av_cold int init_decoder(AVCodecContext *avctx) -@@ -377,6 +378,7 @@ static int display_end_segment(AVCodecContext *avctx, void *data, - { - AVSubtitle *sub = data; - PGSSubContext *ctx = avctx->priv_data; -+ int64_t pts; - - uint16_t rect; - -@@ -386,7 +388,10 @@ static int display_end_segment(AVCodecContext *avctx, void *data, - * not been cleared by a subsequent empty display command. - */ - -+ pts = ctx->pts != AV_NOPTS_VALUE ? ctx->pts : sub->pts; - memset(sub, 0, sizeof(*sub)); -+ sub->pts = pts; -+ ctx->pts = AV_NOPTS_VALUE; - - // Blank if last object_count was 0. - if (!ctx->presentation.object_count) -@@ -431,8 +436,10 @@ static int display_end_segment(AVCodecContext *avctx, void *data, - static int decode(AVCodecContext *avctx, void *data, int *data_size, - AVPacket *avpkt) - { -+ PGSSubContext *ctx = avctx->priv_data; - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; -+ AVSubtitle *sub = data; - - const uint8_t *buf_end; - uint8_t segment_type; -@@ -477,6 +484,7 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, - break; - case PRESENTATION_SEGMENT: - parse_presentation_segment(avctx, buf, segment_length); -+ ctx->pts = sub->pts; - break; - case WINDOW_SEGMENT: - /* -diff --git a/lib/ffmpeg/libavcodec/utils.c b/lib/ffmpeg/libavcodec/utils.c -index 99bf27c..c1cde2c 100644 ---- a/libavcodec/utils.c -+++ b/libavcodec/utils.c -@@ -1396,6 +1396,9 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, - avctx->pkt = avpkt; - *got_sub_ptr = 0; - avcodec_get_subtitle_defaults(sub); -+ if (avctx->time_base.den && avpkt->pts != AV_NOPTS_VALUE) -+ sub->pts = av_rescale_q(avpkt->pts, -+ avctx->time_base, AV_TIME_BASE_Q); - ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt); - if (*got_sub_ptr) - avctx->frame_number++; diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0033-ARM-ac3-fix-ac3_bit_alloc_calc_bap_armv6.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0033-ARM-ac3-fix-ac3_bit_alloc_calc_bap_armv6.patch deleted file mode 100644 index fb5c6d091a..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0033-ARM-ac3-fix-ac3_bit_alloc_calc_bap_armv6.patch +++ /dev/null @@ -1,62 +0,0 @@ -From cd2f98f365dfd83f0debac030413e57a73c7ecd5 Mon Sep 17 00:00:00 2001 -From: Mans Rullgard -Date: Wed, 1 Feb 2012 22:25:10 +0000 -Subject: [PATCH] ARM: ac3: fix ac3_bit_alloc_calc_bap_armv6 - -This function was broken when the start bin was not at the start -of a band. - -Signed-off-by: Mans Rullgard ---- - libavcodec/arm/ac3dsp_armv6.S | 15 +++++++-------- - 1 file changed, 7 insertions(+), 8 deletions(-) - -diff --git a/libavcodec/arm/ac3dsp_armv6.S b/libavcodec/arm/ac3dsp_armv6.S -index b6aee86..df8bfba 100644 ---- a/libavcodec/arm/ac3dsp_armv6.S -+++ b/libavcodec/arm/ac3dsp_armv6.S -@@ -34,24 +34,23 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1 - add r0, r0, r4, lsl #1 @ mask + band - add r4, lr, r4 - add r7, r7, r2 @ bap + start -- ldrb r10, [r4], #1 - 1: - ldrsh r9, [r0], #2 @ mask[band] - mov r8, #0xff0 - sub r9, r9, r12 @ - snr_offset -- mov r11, r10 -- ldrb r10, [r4], #1 @ band_start_tab[band++] -+ ldrb r10, [r4, #1]! @ band_start_tab[++band] - subs r9, r9, r5 @ - floor - it lt - movlt r9, #0 - cmp r10, r3 @ - end - and r9, r9, r8, lsl #1 @ & 0x1fe0 - ite gt -- subgt r8, r3, r11 -- suble r8, r10, r11 -+ subgt r8, r3, r2 -+ suble r8, r10, r2 -+ mov r2, r10 - add r9, r9, r5 @ + floor => m - tst r8, #1 -- add r2, r7, r8 -+ add r11, r7, r8 - bne 3f - b 5f - 2: -@@ -65,9 +64,9 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1 - ldrb lr, [r6, lr] - strb r8, [r7], #1 @ bap[bin] - strb lr, [r7], #1 --5: cmp r7, r2 -+5: cmp r7, r11 - blo 2b -- cmp r3, r11 -+ cmp r3, r10 - bgt 1b - pop {r4-r11,pc} - 3: --- -1.7.10.4 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0034-ARM-fix-h264-chroma-mc-overrides.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0034-ARM-fix-h264-chroma-mc-overrides.patch deleted file mode 100644 index 8b13712f3e..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0034-ARM-fix-h264-chroma-mc-overrides.patch +++ /dev/null @@ -1,257 +0,0 @@ -From 1846ddf0a7870e6862905121d4e9da1c283d6ff6 Mon Sep 17 00:00:00 2001 -From: Mans Rullgard -Date: Fri, 19 Oct 2012 13:39:11 +0100 -Subject: [PATCH] ARM: fix overreads in neon h264 chroma mc - -The loops were reading ahead one line, which could end up outside the -buffer for reference blocks at the edge of the picture. Removing -this readahead has no measurable performance impact. - -Signed-off-by: Mans Rullgard ---- - libavcodec/arm/h264cmc_neon.S | 86 +++++++++++++--------------------------- - 1 files changed, 28 insertions(+), 58 deletions(-) - -diff --git a/libavcodec/arm/h264cmc_neon.S b/libavcodec/arm/h264cmc_neon.S -index c7e5460..3427e36 100644 ---- a/libavcodec/arm/h264cmc_neon.S -+++ b/libavcodec/arm/h264cmc_neon.S -@@ -51,24 +51,20 @@ T cmp r7, #0 - - beq 2f - -- add r5, r1, r2 -- - vdup.8 d0, r4 -- lsl r4, r2, #1 - vdup.8 d1, r12 -- vld1.8 {d4, d5}, [r1], r4 -+ vld1.8 {d4, d5}, [r1], r2 - vdup.8 d2, r6 -- vld1.8 {d6, d7}, [r5], r4 - vdup.8 d3, r7 -- - vext.8 d5, d4, d5, #1 -- vext.8 d7, d6, d7, #1 - --1: pld [r5] -+1: vld1.8 {d6, d7}, [r1], r2 - vmull.u8 q8, d4, d0 - vmlal.u8 q8, d5, d1 -- vld1.8 {d4, d5}, [r1], r4 -+ vext.8 d7, d6, d7, #1 -+ vld1.8 {d4, d5}, [r1], r2 - vmlal.u8 q8, d6, d2 -+ pld [r1] - vext.8 d5, d4, d5, #1 - vmlal.u8 q8, d7, d3 - vmull.u8 q9, d6, d0 -@@ -76,8 +72,7 @@ T cmp r7, #0 - vmlal.u8 q9, d7, d1 - vmlal.u8 q9, d4, d2 - vmlal.u8 q9, d5, d3 -- vld1.8 {d6, d7}, [r5], r4 -- pld [r1] -+ pld [r1, r2] - .ifc \codec,h264 - vrshrn.u16 d16, q8, #6 - vrshrn.u16 d17, q9, #6 -@@ -92,7 +87,6 @@ T cmp r7, #0 - vld1.8 {d21}, [lr,:64], r2 - vrhadd.u8 q8, q8, q10 - .endif -- vext.8 d7, d6, d7, #1 - vst1.8 {d16}, [r0,:64], r2 - vst1.8 {d17}, [r0,:64], r2 - bgt 1b -@@ -106,18 +100,15 @@ T cmp r7, #0 - - beq 4f - -- add r5, r1, r2 -- lsl r4, r2, #1 -- vld1.8 {d4}, [r1], r4 -- vld1.8 {d6}, [r5], r4 -+ vld1.8 {d4}, [r1], r2 - --3: pld [r5] -+3: vld1.8 {d6}, [r1], r2 - vmull.u8 q8, d4, d0 - vmlal.u8 q8, d6, d1 -- vld1.8 {d4}, [r1], r4 -+ vld1.8 {d4}, [r1], r2 - vmull.u8 q9, d6, d0 - vmlal.u8 q9, d4, d1 -- vld1.8 {d6}, [r5], r4 -+ pld [r1] - .ifc \codec,h264 - vrshrn.u16 d16, q8, #6 - vrshrn.u16 d17, q9, #6 -@@ -127,13 +118,13 @@ T cmp r7, #0 - vshrn.u16 d16, q8, #6 - vshrn.u16 d17, q9, #6 - .endif -+ pld [r1, r2] - .ifc \type,avg - vld1.8 {d20}, [lr,:64], r2 - vld1.8 {d21}, [lr,:64], r2 - vrhadd.u8 q8, q8, q10 - .endif - subs r3, r3, #2 -- pld [r1] - vst1.8 {d16}, [r0,:64], r2 - vst1.8 {d17}, [r0,:64], r2 - bgt 3b -@@ -144,16 +135,13 @@ T cmp r7, #0 - vld1.8 {d6, d7}, [r1], r2 - vext.8 d5, d4, d5, #1 - vext.8 d7, d6, d7, #1 -- --5: pld [r1] -+ pld [r1] - subs r3, r3, #2 - vmull.u8 q8, d4, d0 - vmlal.u8 q8, d5, d1 -- vld1.8 {d4, d5}, [r1], r2 - vmull.u8 q9, d6, d0 - vmlal.u8 q9, d7, d1 -- pld [r1] -- vext.8 d5, d4, d5, #1 -+ pld [r1, r2] - .ifc \codec,h264 - vrshrn.u16 d16, q8, #6 - vrshrn.u16 d17, q9, #6 -@@ -168,11 +156,9 @@ T cmp r7, #0 - vld1.8 {d21}, [lr,:64], r2 - vrhadd.u8 q8, q8, q10 - .endif -- vld1.8 {d6, d7}, [r1], r2 -- vext.8 d7, d6, d7, #1 - vst1.8 {d16}, [r0,:64], r2 - vst1.8 {d17}, [r0,:64], r2 -- bgt 5b -+ bgt 4b - - pop {r4-r7, pc} - endfunc -@@ -209,33 +195,29 @@ T cmp r7, #0 - - beq 2f - -- add r5, r1, r2 -- - vdup.8 d0, r4 -- lsl r4, r2, #1 - vdup.8 d1, r12 -- vld1.8 {d4}, [r1], r4 -+ vld1.8 {d4}, [r1], r2 - vdup.8 d2, r6 -- vld1.8 {d6}, [r5], r4 - vdup.8 d3, r7 - - vext.8 d5, d4, d5, #1 -- vext.8 d7, d6, d7, #1 - vtrn.32 d4, d5 -- vtrn.32 d6, d7 - - vtrn.32 d0, d1 - vtrn.32 d2, d3 - --1: pld [r5] -+1: vld1.8 {d6}, [r1], r2 -+ vext.8 d7, d6, d7, #1 -+ vtrn.32 d6, d7 - vmull.u8 q8, d4, d0 - vmlal.u8 q8, d6, d2 -- vld1.8 {d4}, [r1], r4 -+ vld1.8 {d4}, [r1], r2 - vext.8 d5, d4, d5, #1 - vtrn.32 d4, d5 -+ pld [r1] - vmull.u8 q9, d6, d0 - vmlal.u8 q9, d4, d2 -- vld1.8 {d6}, [r5], r4 - vadd.i16 d16, d16, d17 - vadd.i16 d17, d18, d19 - .ifc \codec,h264 -@@ -245,14 +227,12 @@ T cmp r7, #0 - vshrn.u16 d16, q8, #6 - .endif - subs r3, r3, #2 -- pld [r1] -+ pld [r1, r2] - .ifc \type,avg - vld1.32 {d20[0]}, [lr,:32], r2 - vld1.32 {d20[1]}, [lr,:32], r2 - vrhadd.u8 d16, d16, d20 - .endif -- vext.8 d7, d6, d7, #1 -- vtrn.32 d6, d7 - vst1.32 {d16[0]}, [r0,:32], r2 - vst1.32 {d16[1]}, [r0,:32], r2 - bgt 1b -@@ -268,18 +248,15 @@ T cmp r7, #0 - beq 4f - - vext.32 d1, d0, d1, #1 -- add r5, r1, r2 -- lsl r4, r2, #1 -- vld1.32 {d4[0]}, [r1], r4 -- vld1.32 {d4[1]}, [r5], r4 -+ vld1.32 {d4[0]}, [r1], r2 - --3: pld [r5] -+3: vld1.32 {d4[1]}, [r1], r2 - vmull.u8 q8, d4, d0 -- vld1.32 {d4[0]}, [r1], r4 -+ vld1.32 {d4[0]}, [r1], r2 - vmull.u8 q9, d4, d1 -- vld1.32 {d4[1]}, [r5], r4 - vadd.i16 d16, d16, d17 - vadd.i16 d17, d18, d19 -+ pld [r1] - .ifc \codec,h264 - vrshrn.u16 d16, q8, #6 - .else -@@ -292,7 +269,7 @@ T cmp r7, #0 - vrhadd.u8 d16, d16, d20 - .endif - subs r3, r3, #2 -- pld [r1] -+ pld [r1, r2] - vst1.32 {d16[0]}, [r0,:32], r2 - vst1.32 {d16[1]}, [r0,:32], r2 - bgt 3b -@@ -305,13 +282,9 @@ T cmp r7, #0 - vext.8 d7, d6, d7, #1 - vtrn.32 d4, d5 - vtrn.32 d6, d7 -- --5: vmull.u8 q8, d4, d0 -+ vmull.u8 q8, d4, d0 - vmull.u8 q9, d6, d0 - subs r3, r3, #2 -- vld1.8 {d4}, [r1], r2 -- vext.8 d5, d4, d5, #1 -- vtrn.32 d4, d5 - vadd.i16 d16, d16, d17 - vadd.i16 d17, d18, d19 - pld [r1] -@@ -326,13 +299,10 @@ T cmp r7, #0 - vld1.32 {d20[1]}, [lr,:32], r2 - vrhadd.u8 d16, d16, d20 - .endif -- vld1.8 {d6}, [r1], r2 -- vext.8 d7, d6, d7, #1 -- vtrn.32 d6, d7 - pld [r1] - vst1.32 {d16[0]}, [r0,:32], r2 - vst1.32 {d16[1]}, [r0,:32], r2 -- bgt 5b -+ bgt 4b - - pop {r4-r7, pc} - endfunc --- -1.7.2.5 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0035-ffmpeg-fixed-missing-S_DVBSUB-subtitles.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0035-ffmpeg-fixed-missing-S_DVBSUB-subtitles.patch deleted file mode 100644 index 0e48c68438..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0035-ffmpeg-fixed-missing-S_DVBSUB-subtitles.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 9066d83f0f237d90fe0c2d9b6202bb8cd59a6562 Mon Sep 17 00:00:00 2001 -From: Allan Kristensen -Date: Fri, 21 Dec 2012 21:04:18 +0100 -Subject: [PATCH 1/1] [ffmpeg] fixed missing S_DVBSUB subtitles - ---- - libavformat/matroska.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/libavformat/matroska.c b/libavformat/matroska.c -index 2f5b617..11c2fa5 100644 ---- a/libavformat/matroska.c -+++ b/libavformat/matroska.c -@@ -59,6 +59,7 @@ const CodecTags ff_mkv_codec_tags[]={ - {"S_ASS" , CODEC_ID_SSA}, - {"S_SSA" , CODEC_ID_SSA}, - {"S_VOBSUB" , CODEC_ID_DVD_SUBTITLE}, -+ {"S_DVBSUB" , CODEC_ID_DVB_SUBTITLE}, - {"S_HDMV/PGS" , CODEC_ID_HDMV_PGS_SUBTITLE}, - - {"V_DIRAC" , CODEC_ID_DIRAC}, --- -1.8.0 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0036-Provide-a-monotonic-timestamp-to-the-outside-world.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0036-Provide-a-monotonic-timestamp-to-the-outside-world.patch deleted file mode 100644 index 1db0d7efd7..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0036-Provide-a-monotonic-timestamp-to-the-outside-world.patch +++ /dev/null @@ -1,337 +0,0 @@ -From b2d3b83a73d71833f84485adb8a6f4c0959b4c4e Mon Sep 17 00:00:00 2001 -From: Harald Axmann -Date: Sun, 16 Dec 2012 16:07:36 +0100 -Subject: [PATCH] lavf: Provide a monotonic timestamp to the outside world - -This detects and removes single timestamp wraps, which fixes seeking for affected video files. ---- - libavformat/avformat.h | 37 +++++++++++ - libavformat/options.c | 1 + - libavformat/utils.c | 123 ++++++++++++++++++++++++++++++++++--- - 3 files changed, 151 insertions(+), 10 deletions(-) - -diff --git a/libavformat/avformat.h b/libavformat/avformat.h -index c76ac71..40f71cb 100644 ---- a/libavformat/avformat.h -+++ b/libavformat/avformat.h -@@ -627,6 +627,13 @@ enum AVStreamParseType { - #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */ - #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */ - -+/* -+ * Options for behavior on timestamp wrap detection. -+ */ -+#define AV_PTS_WRAP_IGNORE 0 ///< ignore the wrap -+#define AV_PTS_WRAP_ADD_OFFSET 1 ///< add the format specific offset on wrap detection -+#define AV_PTS_WRAP_SUB_OFFSET -1 ///< subtract the format specific offset on wrap detection -+ - /** - * Stream structure. - * New fields can be added to the end with minor version bumps. -@@ -857,6 +864,24 @@ enum AVStreamParseType { - - int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ - #endif -+ -+ /** -+ * Internal data to check for wrapping of the time stamp -+ */ -+ int64_t pts_wrap_reference; -+ -+ /** -+ * Options for behavior, when a wrap is detected. -+ * -+ * Defined by AV_PTS_WRAP_ values. -+ * -+ * If correction is enabled, there are two possibilities: -+ * If the first time stamp is near the wrap point, the wrap offset -+ * will be subtracted, which will create negative time stamps. -+ * Otherwise the offset will be added. -+ */ -+ int pts_wrap_behavior; -+ - } AVStream; - - #define AV_PROGRAM_RUNNING 1 -@@ -878,6 +903,10 @@ enum AVStreamParseType { - int program_num; - int pmt_pid; - int pcr_pid; -+ -+ int64_t pts_wrap_reference; ///< reference dts for wrap detection -+ int pts_wrap_behavior; ///< behavior on wrap detection -+ - } AVProgram; - - #define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present -@@ -1234,6 +1263,14 @@ enum AVStreamParseType { - /* av_seek_frame() support */ - int64_t data_offset; /**< offset of the first packet */ - #endif -+ -+ /** -+ * Correct single timestamp overflows -+ * - encoding: unused -+ * - decoding: Set by user via AVOPtions (NO direct access) -+ */ -+ unsigned int correct_ts_overflow; -+ - } AVFormatContext; - - typedef struct AVPacketList { -diff --git a/libavformat/options.c b/libavformat/options.c -index 31acbd3..666d05e 100644 ---- a/libavformat/options.c -+++ b/libavformat/options.c -@@ -127,6 +127,7 @@ static const AVClass *format_child_class_next(const AVClass *prev) - {"careful", "consider things that violate the spec and have not been seen in the wild as errors", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CAREFUL }, INT_MIN, INT_MAX, D, "err_detect"}, - {"compliant", "consider all spec non compliancies as errors", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_COMPLIANT }, INT_MIN, INT_MAX, D, "err_detect"}, - {"aggressive", "consider things that a sane encoder shouldnt do as an error", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_AGGRESSIVE }, INT_MIN, INT_MAX, D, "err_detect"}, -+{"correct_ts_overflow", "correct single timestamp overflows", OFFSET(correct_ts_overflow), AV_OPT_TYPE_INT, {.dbl = 1}, 0, 1, D}, - {NULL}, - }; - -diff --git a/libavformat/utils.c b/libavformat/utils.c -index 63f89dd..89e5ed4 100644 ---- a/libavformat/utils.c -+++ b/libavformat/utils.c -@@ -122,6 +122,27 @@ static void frac_add(AVFrac *f, int64_t incr) - f->num = num; - } - -+/** -+ * Wrap a given time stamp, if there is an indication for an overflow -+ * -+ * @param st stream -+ * @param timestamp the time stamp to wrap -+ * @return resulting time stamp -+ */ -+static int64_t wrap_timestamp(AVStream *st, int64_t timestamp) -+{ -+ if (st->pts_wrap_behavior != AV_PTS_WRAP_IGNORE && -+ st->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) { -+ if (st->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET && -+ timestamp < st->pts_wrap_reference) -+ return timestamp + (1LL<pts_wrap_bits); -+ else if (st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET && -+ timestamp >= st->pts_wrap_reference) -+ return timestamp - (1LL<pts_wrap_bits); -+ } -+ return timestamp; -+} -+ - /** head of registered input format linked list */ - static AVInputFormat *first_iformat = NULL; - /** head of registered output format linked list */ -@@ -798,6 +819,8 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt) - } - - st= s->streams[pkt->stream_index]; -+ pkt->dts = wrap_timestamp(st, pkt->dts); -+ pkt->pts = wrap_timestamp(st, pkt->pts); - - switch(st->codec->codec_type){ - case AVMEDIA_TYPE_VIDEO: -@@ -948,8 +971,67 @@ static int is_intra_only(AVCodecContext *enc){ - return 0; - } - -+static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_index) -+{ -+ if (s->correct_ts_overflow && st->pts_wrap_bits != 64 && -+ st->pts_wrap_reference == AV_NOPTS_VALUE && st->first_dts != AV_NOPTS_VALUE) { -+ int i; -+ -+ // reference time stamp should be 60 s before first time stamp -+ int64_t pts_wrap_reference = st->first_dts - av_rescale(60, st->time_base.den, st->time_base.num); -+ // if first time stamp is not more than 1/8 and 60s before the wrap point, subtract rather than add wrap offset -+ int pts_wrap_behavior = (st->first_dts < (1LL<pts_wrap_bits) - (1LL<pts_wrap_bits-3)) || -+ (st->first_dts < (1LL<pts_wrap_bits) - av_rescale(60, st->time_base.den, st->time_base.num)) ? -+ AV_PTS_WRAP_ADD_OFFSET : AV_PTS_WRAP_SUB_OFFSET; -+ -+ AVProgram *first_program = av_find_program_from_stream(s, NULL, stream_index); -+ -+ if (!first_program) { -+ int default_stream_index = av_find_default_stream_index(s); -+ if (s->streams[default_stream_index]->pts_wrap_reference == AV_NOPTS_VALUE) { -+ for (i=0; inb_streams; i++) { -+ s->streams[i]->pts_wrap_reference = pts_wrap_reference; -+ s->streams[i]->pts_wrap_behavior = pts_wrap_behavior; -+ } -+ } -+ else { -+ st->pts_wrap_reference = s->streams[default_stream_index]->pts_wrap_reference; -+ st->pts_wrap_behavior = s->streams[default_stream_index]->pts_wrap_behavior; -+ } -+ } -+ else { -+ AVProgram *program = first_program; -+ while (program) { -+ if (program->pts_wrap_reference != AV_NOPTS_VALUE) { -+ pts_wrap_reference = program->pts_wrap_reference; -+ pts_wrap_behavior = program->pts_wrap_behavior; -+ break; -+ } -+ program = av_find_program_from_stream(s, program, stream_index); -+ } -+ -+ // update every program with differing pts_wrap_reference -+ program = first_program; -+ while(program) { -+ if (program->pts_wrap_reference != pts_wrap_reference) { -+ for (i=0; inb_stream_indexes; i++) { -+ s->streams[program->stream_index[i]]->pts_wrap_reference = pts_wrap_reference; -+ s->streams[program->stream_index[i]]->pts_wrap_behavior = pts_wrap_behavior; -+ } -+ -+ program->pts_wrap_reference = pts_wrap_reference; -+ program->pts_wrap_behavior = pts_wrap_behavior; -+ } -+ program = av_find_program_from_stream(s, program, stream_index); -+ } -+ } -+ return 1; -+ } -+ return 0; -+} -+ - static void update_initial_timestamps(AVFormatContext *s, int stream_index, -- int64_t dts, int64_t pts) -+ int64_t dts, int64_t pts, AVPacket *pkt) - { - AVStream *st= s->streams[stream_index]; - AVPacketList *pktl= s->packet_buffer; -@@ -973,6 +1055,16 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, - if(st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != AV_NOPTS_VALUE) - st->start_time= pktl->pkt.pts; - } -+ -+ if (update_wrap_reference(s, st, stream_index) && st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET) { -+ // correct first time stamps to negative values -+ st->first_dts = wrap_timestamp(st, st->first_dts); -+ st->cur_dts = wrap_timestamp(st, st->cur_dts); -+ pkt->dts = wrap_timestamp(st, pkt->dts); -+ pkt->pts = wrap_timestamp(st, pkt->pts); -+ pts = wrap_timestamp(st, pts); -+ } -+ - if (st->start_time == AV_NOPTS_VALUE) - st->start_time = pts; - } -@@ -1104,7 +1196,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, - /* PTS = presentation timestamp */ - if (pkt->dts == AV_NOPTS_VALUE) - pkt->dts = st->last_IP_pts; -- update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts); -+ update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt); - if (pkt->dts == AV_NOPTS_VALUE) - pkt->dts = st->cur_dts; - -@@ -1131,7 +1223,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, - /* presentation is not delayed : PTS and DTS are the same */ - if(pkt->pts == AV_NOPTS_VALUE) - pkt->pts = pkt->dts; -- update_initial_timestamps(s, pkt->stream_index, pkt->pts, pkt->pts); -+ update_initial_timestamps(s, pkt->stream_index, pkt->pts, pkt->pts, pkt); - if(pkt->pts == AV_NOPTS_VALUE) - pkt->pts = st->cur_dts; - pkt->dts = pkt->pts; -@@ -1147,7 +1239,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, - if(pkt->dts == AV_NOPTS_VALUE) - pkt->dts= st->pts_buffer[0]; - if(st->codec->codec_id == CODEC_ID_H264){ // we skipped it above so we try here -- update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts); // this should happen on the first packet -+ update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt); // this should happen on the first packet - } - if(pkt->dts > st->cur_dts) - st->cur_dts = pkt->dts; -@@ -1550,6 +1642,7 @@ int ff_add_index_entry(AVIndexEntry **index_entries, - int av_add_index_entry(AVStream *st, - int64_t pos, int64_t timestamp, int size, int distance, int flags) - { -+ timestamp = wrap_timestamp(st, timestamp); - return ff_add_index_entry(&st->index_entries, &st->nb_index_entries, - &st->index_entries_allocated_size, pos, - timestamp, size, distance, flags); -@@ -1602,6 +1695,12 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts - } - #endif - -+static int64_t ff_read_timestamp(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit, -+ int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )) -+{ -+ return wrap_timestamp(s->streams[stream_index], read_timestamp(s, stream_index, ppos, pos_limit)); -+} -+ - int ff_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags) - { - AVInputFormat *avif= s->iformat; -@@ -1689,7 +1788,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, - - if(ts_min == AV_NOPTS_VALUE){ - pos_min = s->data_offset; -- ts_min = read_timestamp(s, stream_index, &pos_min, INT64_MAX); -+ ts_min = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp); - if (ts_min == AV_NOPTS_VALUE) - return -1; - } -@@ -1705,7 +1804,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, - pos_max = filesize - 1; - do{ - pos_max -= step; -- ts_max = read_timestamp(s, stream_index, &pos_max, pos_max + step); -+ ts_max = ff_read_timestamp(s, stream_index, &pos_max, pos_max + step, read_timestamp); - step += step; - }while(ts_max == AV_NOPTS_VALUE && pos_max >= step); - if (ts_max == AV_NOPTS_VALUE) -@@ -1713,7 +1812,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, - - for(;;){ - int64_t tmp_pos= pos_max + 1; -- int64_t tmp_ts= read_timestamp(s, stream_index, &tmp_pos, INT64_MAX); -+ int64_t tmp_ts= ff_read_timestamp(s, stream_index, &tmp_pos, INT64_MAX, read_timestamp); - if(tmp_ts == AV_NOPTS_VALUE) - break; - ts_max= tmp_ts; -@@ -1760,7 +1859,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, - pos= pos_limit; - start_pos= pos; - -- ts = read_timestamp(s, stream_index, &pos, INT64_MAX); //may pass pos_limit instead of -1 -+ ts = ff_read_timestamp(s, stream_index, &pos, INT64_MAX, read_timestamp); //may pass pos_limit instead of -1 - if(pos == pos_max) - no_change++; - else -@@ -1788,9 +1887,9 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, - ts = (flags & AVSEEK_FLAG_BACKWARD) ? ts_min : ts_max; - #if 0 - pos_min = pos; -- ts_min = read_timestamp(s, stream_index, &pos_min, INT64_MAX); -+ ts_min = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp); - pos_min++; -- ts_max = read_timestamp(s, stream_index, &pos_min, INT64_MAX); -+ ts_max = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp); - av_dlog(s, "pos=0x%"PRIx64" %"PRId64"<=%"PRId64"<=%"PRId64"\n", - pos, ts_min, target_ts, ts_max); - #endif -@@ -2992,6 +3091,8 @@ AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c) - st->cur_dts = 0; - st->first_dts = AV_NOPTS_VALUE; - st->probe_packets = MAX_PROBE_PACKETS; -+ st->pts_wrap_reference = AV_NOPTS_VALUE; -+ st->pts_wrap_behavior = AV_PTS_WRAP_IGNORE; - - /* default pts setting is MPEG-like */ - avpriv_set_pts_info(st, 33, 1, 90000); -@@ -3025,6 +3126,8 @@ AVProgram *av_new_program(AVFormatContext *ac, int id) - program->discard = AVDISCARD_NONE; - } - program->id = id; -+ program->pts_wrap_reference = AV_NOPTS_VALUE; -+ program->pts_wrap_behavior = AV_PTS_WRAP_IGNORE; - - return program; - } --- -1.7.10 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0037-latm_fix_initialization_on_some_streams.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0037-latm_fix_initialization_on_some_streams.patch deleted file mode 100644 index de9e161e41..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0037-latm_fix_initialization_on_some_streams.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 06d713fefaf19cb4dfb83126ba1c078d6dcabc67 Mon Sep 17 00:00:00 2001 -From: xbmc -Date: Tue, 25 Dec 2012 08:35:36 +0100 -Subject: [PATCH] ffmpeg: backport latm: fix initialization on some streams - when no extradata is available: - d039b6074ca68da9b6dc88d8bb40056fee9fecb6 - ---- - libavcodec/aacdec.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c -index 5c6404e..ad2991b 100644 ---- a/libavcodec/aacdec.c -+++ b/libavcodec/aacdec.c -@@ -2403,7 +2403,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, - if (bits_consumed < 0) - return AVERROR_INVALIDDATA; - -- if (ac->m4ac.sample_rate != m4ac.sample_rate || -+ if (!latmctx->initialized || -+ ac->m4ac.sample_rate != m4ac.sample_rate || - ac->m4ac.chan_config != m4ac.chan_config) { - - av_log(avctx, AV_LOG_INFO, "audio config changed\n"); --- -1.7.10 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0038-Fixed_forced_subtitles_display_in_PGS_stream.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0038-Fixed_forced_subtitles_display_in_PGS_stream.patch deleted file mode 100644 index d6e3b5e3ec..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-0038-Fixed_forced_subtitles_display_in_PGS_stream.patch +++ /dev/null @@ -1,284 +0,0 @@ -From 3b1409c1a1f0ce486f95087fa0b6ff5bfb841464 Mon Sep 17 00:00:00 2001 -From: GreenOnyx -Date: Thu, 27 Dec 2012 00:18:40 -0600 -Subject: [PATCH] ffmpeg: Fixed forced subtitles display in PGS stream - -Associated ffmpeg commits: - -https://github.com/FFmpeg/FFmpeg/commit/36436a4032b022f5439fa86a0986065d24cd51fd -Add option forced_subs_only for Bluray subtitles. -2012-01-30 04:25:59 - -https://github.com/FFmpeg/FFmpeg/commit/1885ffb03d0af28e6bac2bcc8725fa15b93f6ac9 -PGS subtitles: Expose forced flag -2012-10-20 11:56:11 - -https://github.com/FFmpeg/FFmpeg/commit/1c5805521c3e406886341d752ebf38f8d41e1d13 -PGS subtitles: Set AVSubtitle pts value -2012-11-02 11:30:39 - -https://github.com/FFmpeg/FFmpeg/commit/6549a9b75333027f66cdaac450a66b6a6186fc6e -pgssubdec: remove unused variable -2012-11-28 10:20:08 - -https://github.com/FFmpeg/FFmpeg/commit/1f46b50a9591f68b697e943f829c79a4f4829dd6 -Added AVClass for AVSubtitleRect -2012-04-18 01:08:25 ---- - libavcodec/avcodec.h | 18 +++++++++++++ - libavcodec/dvdsubdec.c | 1 + - libavcodec/options.c | 25 +++++++++++++++++ - libavcodec/pgssubdec.c | 53 ++++++++++++++++++++++++++----------- - 4 files changed, 81 insertions(+), 16 deletions(-) - -diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h -index 6996c92..585414b 100644 ---- a/libavcodec/avcodec.h -+++ b/libavcodec/avcodec.h -@@ -3245,6 +3245,12 @@ enum AVFieldOrder { - int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far - int64_t pts_correction_last_pts; /// PTS of the last frame - int64_t pts_correction_last_dts; /// DTS of the last frame -+ /** -+ * Requests that only forced subpictures be decoded. -+ * - decoding: set by user -+ * - encoding: unused -+ */ -+ int forced_subs_only; - - } AVCodecContext; - -@@ -3488,6 +3494,8 @@ enum AVSubtitleType { - SUBTITLE_ASS, - }; - -+#define AV_SUBTITLE_FLAG_FORCED 0x00000001 -+ - typedef struct AVSubtitleRect { - int x; ///< top left corner of pict, undefined when pict is not set - int y; ///< top left corner of pict, undefined when pict is not set -@@ -3510,6 +3518,8 @@ enum AVSubtitleType { - * struct. - */ - char *ass; -+ -+ int flags; - } AVSubtitleRect; - - typedef struct AVSubtitle { -@@ -4895,6 +4905,14 @@ enum AVLockOp { - const AVClass *avcodec_get_frame_class(void); - - /** -+ * Get the AVClass for AVSubtitleRect. It can be used in combination with -+ * AV_OPT_SEARCH_FAKE_OBJ for examining options. -+ * -+ * @see av_opt_find(). -+ */ -+const AVClass *avcodec_get_subtitle_rect_class(void); -+ -+/** - * @return a positive value if s is open (i.e. avcodec_open2() was called on it - * with no corresponding avcodec_close()), 0 otherwise. - */ -diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c -index d0d13ee..46a0b8d 100644 ---- a/libavcodec/dvdsubdec.c -+++ b/libavcodec/dvdsubdec.c -@@ -375,6 +375,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header, - sub_header->rects[0]->h = h; - sub_header->rects[0]->type = SUBTITLE_BITMAP; - sub_header->rects[0]->pict.linesize[0] = w; -+ sub_header->rects[0]->flags = is_menu ? AV_SUBTITLE_FLAG_FORCED : 0; - } - } - if (next_cmd_pos < cmd_pos) { -diff --git a/libavcodec/options.c b/libavcodec/options.c -index 5f940a0..ae62e75 100644 ---- a/libavcodec/options.c -+++ b/libavcodec/options.c -@@ -730,3 +730,28 @@ const AVClass *avcodec_get_frame_class(void) - { - return &av_frame_class; - } -+ -+#define SROFFSET(x) offsetof(AVSubtitleRect,x) -+ -+static const AVOption subtitle_rect_options[]={ -+{"x", "", SROFFSET(x), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0}, -+{"y", "", SROFFSET(y), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0}, -+{"w", "", SROFFSET(w), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0}, -+{"h", "", SROFFSET(h), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0}, -+{"type", "", SROFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0}, -+{"flags", "", SROFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, 1, 0, "flags"}, -+{"forced", "", SROFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, 1, 0}, -+{NULL}, -+}; -+ -+static const AVClass av_subtitle_rect_class = { -+ .class_name = "AVSubtitleRect", -+ .item_name = NULL, -+ .option = subtitle_rect_options, -+ .version = LIBAVUTIL_VERSION_INT, -+}; -+ -+const AVClass *avcodec_get_subtitle_rect_class(void) -+{ -+ return &av_subtitle_rect_class; -+} -\ No newline at end of file -diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c -index 02e650a..83d7f43 100644 ---- a/libavcodec/pgssubdec.c -+++ b/libavcodec/pgssubdec.c -@@ -29,6 +29,7 @@ - #include "bytestream.h" - #include "libavutil/colorspace.h" - #include "libavutil/imgutils.h" -+#include "libavutil/opt.h" - - #define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - -@@ -44,12 +45,14 @@ enum SegmentType { - int x; - int y; - int picture_id; -+ int composition; - } PGSSubPictureReference; - - typedef struct PGSSubPresentation { - int id_number; - int object_count; - PGSSubPictureReference *objects; -+ int64_t pts; - } PGSSubPresentation; - - typedef struct PGSSubPicture { -@@ -61,10 +64,11 @@ enum SegmentType { - } PGSSubPicture; - - typedef struct PGSSubContext { -+ AVClass *class; - PGSSubPresentation presentation; - uint32_t clut[256]; - PGSSubPicture pictures[UINT16_MAX]; -- int64_t pts; -+ int forced_subs_only; - } PGSSubContext; - - static av_cold int init_decoder(AVCodecContext *avctx) -@@ -284,10 +288,10 @@ static void parse_palette_segment(AVCodecContext *avctx, - * @param buf pointer to the packet to process - * @param buf_size size of packet to process - * @todo TODO: Implement cropping -- * @todo TODO: Implement forcing of subtitles - */ - static void parse_presentation_segment(AVCodecContext *avctx, -- const uint8_t *buf, int buf_size) -+ const uint8_t *buf, int buf_size, -+ int64_t pts) - { - PGSSubContext *ctx = avctx->priv_data; - -@@ -296,6 +300,8 @@ static void parse_presentation_segment(AVCodecContext *avctx, - - uint16_t object_index; - -+ ctx->presentation.pts = pts; -+ - av_dlog(avctx, "Video Dimensions %dx%d\n", - w, h); - if (av_image_check_size(w, h, 0, avctx) >= 0) -@@ -336,12 +342,10 @@ static void parse_presentation_segment(AVCodecContext *avctx, - PGSSubPictureReference *reference = &ctx->presentation.objects[object_index]; - reference->picture_id = bytestream_get_be16(&buf); - -- /* -- * Skip 2 bytes of unknown: -- * window_id_ref, -- * composition_flag (0x80 - object cropped, 0x40 - object forced) -- */ -- buf += 2; -+ /* Skip window_id_ref */ -+ buf++; -+ /* composition_flag (0x80 - object cropped, 0x40 - object forced) */ -+ reference->composition = bytestream_get_byte(&buf); - - reference->x = bytestream_get_be16(&buf); - reference->y = bytestream_get_be16(&buf); -@@ -388,10 +392,10 @@ static int display_end_segment(AVCodecContext *avctx, void *data, - * not been cleared by a subsequent empty display command. - */ - -- pts = ctx->pts != AV_NOPTS_VALUE ? ctx->pts : sub->pts; -+ pts = ctx->presentation.pts != AV_NOPTS_VALUE ? ctx->presentation.pts : sub->pts; - memset(sub, 0, sizeof(*sub)); - sub->pts = pts; -- ctx->pts = AV_NOPTS_VALUE; -+ ctx->presentation.pts = AV_NOPTS_VALUE; - - // Blank if last object_count was 0. - if (!ctx->presentation.object_count) -@@ -427,6 +431,10 @@ static int display_end_segment(AVCodecContext *avctx, void *data, - sub->rects[rect]->nb_colors = 256; - sub->rects[rect]->pict.data[1] = av_mallocz(AVPALETTE_SIZE); - -+ /* Copy the forced flag */ -+ sub->rects[rect]->flags = (ctx->presentation.objects[rect].composition & 0x40) != 0 ? AV_SUBTITLE_FLAG_FORCED : 0; -+ -+ if (!ctx->forced_subs_only || ctx->presentation.objects[rect].composition & 0x40) - memcpy(sub->rects[rect]->pict.data[1], ctx->clut, sub->rects[rect]->nb_colors * sizeof(uint32_t)); - } - -@@ -436,7 +444,6 @@ static int display_end_segment(AVCodecContext *avctx, void *data, - static int decode(AVCodecContext *avctx, void *data, int *data_size, - AVPacket *avpkt) - { -- PGSSubContext *ctx = avctx->priv_data; - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; - AVSubtitle *sub = data; -@@ -483,8 +490,7 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, - parse_picture_segment(avctx, buf, segment_length); - break; - case PRESENTATION_SEGMENT: -- parse_presentation_segment(avctx, buf, segment_length); -- ctx->pts = sub->pts; -+ parse_presentation_segment(avctx, buf, segment_length, sub->pts); - break; - case WINDOW_SEGMENT: - /* -@@ -511,6 +517,20 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, - return buf_size; - } - -+#define OFFSET(x) offsetof(PGSSubContext, x) -+#define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM -+static const AVOption options[] = { -+ {"forced_subs_only", "Only show forced subtitles", OFFSET(forced_subs_only), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, SD}, -+ { NULL }, -+}; -+ -+static const AVClass pgsdec_class = { -+ .class_name = "PGS subtitle decoder", -+ .item_name = av_default_item_name, -+ .option = options, -+ .version = LIBAVUTIL_VERSION_INT, -+}; -+ - AVCodec ff_pgssub_decoder = { - .name = "pgssub", - .type = AVMEDIA_TYPE_SUBTITLE, -@@ -519,5 +539,6 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, - .init = init_decoder, - .close = close_decoder, - .decode = decode, -- .long_name = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"), --}; -+ .long_name = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"), -+ .priv_class = &pgsdec_class, -+}; -\ No newline at end of file --- -1.7.10 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-905.01-VFP_acceleration.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-905.01-VFP_acceleration.patch deleted file mode 100644 index 48da429b70..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-905.01-VFP_acceleration.patch +++ /dev/null @@ -1,4019 +0,0 @@ -From d4b2cd80ab6f54590fecfbfbf0a414cec1cf1204 Mon Sep 17 00:00:00 2001 -From: Ben Avison -Date: Fri, 14 Jun 2013 16:07:53 +0100 -Subject: [PATCH 50/55] Add VFP-accelerated version of synth_filter_float(), - used by DTS Coherent Acoustics decoder - ---- - libavcodec/arm/Makefile | 1 + - libavcodec/arm/fft_init_arm.c | 8 ++ - libavcodec/arm/synth_filter_vfp.S | 206 +++++++++++++++++++++++++++ - 3 files changed, 215 insertions(+) - create mode 100644 libavcodec/arm/synth_filter_vfp.S - -diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile -index 52709b6..b8b4df2 100644 ---- a/libavcodec/arm/Makefile -+++ b/libavcodec/arm/Makefile -@@ -37,6 +37,7 @@ OBJS-$(HAVE_ARMV6) += arm/dsputil_init_armv6.o \ - $(ARMV6-OBJS-yes) - - VFP-OBJS-$(HAVE_ARMV6) += arm/fmtconvert_vfp.o \ -+ arm/synth_filter_vfp.o - - OBJS-$(HAVE_ARMVFP) += arm/dsputil_vfp.o \ - arm/dsputil_init_vfp.o \ -diff --git a/libavcodec/arm/fft_init_arm.c b/libavcodec/arm/fft_init_arm.c -index cdb64e7..605b3dd 100644 ---- a/libavcodec/arm/fft_init_arm.c -+++ b/libavcodec/arm/fft_init_arm.c -@@ -31,6 +31,12 @@ - - void ff_rdft_calc_neon(struct RDFTContext *s, FFTSample *z); - -+void ff_synth_filter_float_vfp(FFTContext *imdct, -+ float *synth_buf_ptr, int *synth_buf_offset, -+ float synth_buf2[32], const float window[512], -+ float out[32], const float in[32], -+ float scale); -+ - void ff_synth_filter_float_neon(FFTContext *imdct, - float *synth_buf_ptr, int *synth_buf_offset, - float synth_buf2[32], const float window[512], -@@ -62,6 +68,8 @@ av_cold void ff_rdft_init_arm(RDFTContext *s) - #if CONFIG_DCA_DECODER - av_cold void ff_synth_filter_init_arm(SynthFilterContext *s) - { -+ if (HAVE_ARMVFP) -+ s->synth_filter_float = ff_synth_filter_float_vfp; - if (HAVE_NEON) - s->synth_filter_float = ff_synth_filter_float_neon; - } -diff --git a/libavcodec/arm/synth_filter_vfp.S b/libavcodec/arm/synth_filter_vfp.S -new file mode 100644 -index 0000000..8c54267 ---- /dev/null -+++ b/libavcodec/arm/synth_filter_vfp.S -@@ -0,0 +1,206 @@ -+/* -+ * Copyright (c) 2013 RISC OS Open Ltd -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ * -+ * Author: Ben Avison -+ */ -+ -+#include "libavcodec/arm/asm.S" -+ -+IMDCT .req r0 -+ORIG_P_SB .req r1 -+P_SB_OFF .req r2 -+I .req r0 -+P_SB2_UP .req r1 -+OLDFPSCR .req r2 -+P_SB2_DN .req r3 -+P_WIN_DN .req r4 -+P_OUT_DN .req r5 -+P_SB .req r6 -+J_WRAP .req r7 -+P_WIN_UP .req r12 -+P_OUT_UP .req r14 -+ -+SCALE .req s0 -+SBUF_DAT_REV0 .req s4 -+SBUF_DAT_REV1 .req s5 -+SBUF_DAT_REV2 .req s6 -+SBUF_DAT_REV3 .req s7 -+VA0 .req s8 -+VA3 .req s11 -+VB0 .req s12 -+VB3 .req s15 -+VC0 .req s8 -+VC3 .req s11 -+VD0 .req s12 -+VD3 .req s15 -+SBUF_DAT0 .req s16 -+SBUF_DAT1 .req s17 -+SBUF_DAT2 .req s18 -+SBUF_DAT3 .req s19 -+SBUF_DAT_ALT0 .req s20 -+SBUF_DAT_ALT1 .req s21 -+SBUF_DAT_ALT2 .req s22 -+SBUF_DAT_ALT3 .req s23 -+WIN_DN_DAT0 .req s24 -+WIN_UP_DAT0 .req s28 -+ -+ -+.macro inner_loop half, tail, head -+ .if (OFFSET & (64*4)) == 0 @ even numbered call -+ SBUF_DAT_THIS0 .req SBUF_DAT0 -+ SBUF_DAT_THIS1 .req SBUF_DAT1 -+ SBUF_DAT_THIS2 .req SBUF_DAT2 -+ SBUF_DAT_THIS3 .req SBUF_DAT3 -+ .ifnc "\head","" -+ vldr d8, [P_SB, #OFFSET] @ d8 = SBUF_DAT -+ vldr d9, [P_SB, #OFFSET+8] -+ .endif -+ .else -+ SBUF_DAT_THIS0 .req SBUF_DAT_ALT0 -+ SBUF_DAT_THIS1 .req SBUF_DAT_ALT1 -+ SBUF_DAT_THIS2 .req SBUF_DAT_ALT2 -+ SBUF_DAT_THIS3 .req SBUF_DAT_ALT3 -+ .ifnc "\head","" -+ vldr d10, [P_SB, #OFFSET] @ d10 = SBUF_DAT_ALT -+ vldr d11, [P_SB, #OFFSET+8] -+ .endif -+ .endif -+ .ifnc "\tail","" -+ .ifc "\half","ab" -+ vmls.f VA0, SBUF_DAT_REV0, WIN_DN_DAT0 @ all operands treated as vectors -+ .else -+ vmla.f VD0, SBUF_DAT_REV0, WIN_DN_DAT0 @ all operands treated as vectors -+ .endif -+ .endif -+ .ifnc "\head","" -+ vldr d14, [P_WIN_UP, #OFFSET] @ d14 = WIN_UP_DAT -+ vldr d15, [P_WIN_UP, #OFFSET+8] -+ vldr d12, [P_WIN_DN, #OFFSET] @ d12 = WIN_DN_DAT -+ vldr d13, [P_WIN_DN, #OFFSET+8] -+ vmov SBUF_DAT_REV3, SBUF_DAT_THIS0 -+ vmov SBUF_DAT_REV2, SBUF_DAT_THIS1 -+ vmov SBUF_DAT_REV1, SBUF_DAT_THIS2 -+ vmov SBUF_DAT_REV0, SBUF_DAT_THIS3 -+ .ifc "\half","ab" -+ vmla.f VB0, SBUF_DAT_THIS0, WIN_UP_DAT0 -+ .else -+ vmla.f VC0, SBUF_DAT_THIS0, WIN_UP_DAT0 -+ .endif -+ teq J_WRAP, #J -+ bne 2f @ strongly predictable, so better than cond exec in this case -+ sub P_SB, P_SB, #512*4 -+2: -+ .set J, J - 64 -+ .set OFFSET, OFFSET + 64*4 -+ .endif -+ .unreq SBUF_DAT_THIS0 -+ .unreq SBUF_DAT_THIS1 -+ .unreq SBUF_DAT_THIS2 -+ .unreq SBUF_DAT_THIS3 -+.endm -+ -+ -+/* void ff_synth_filter_float_vfp(FFTContext *imdct, -+ * float *synth_buf_ptr, int *synth_buf_offset, -+ * float synth_buf2[32], const float window[512], -+ * float out[32], const float in[32], float scale) -+ */ -+function ff_synth_filter_float_vfp, export=1 -+ push {r3-r7,lr} -+ vpush {s16-s31} -+ ldr lr, [P_SB_OFF] -+ add a2, ORIG_P_SB, lr, LSL #2 @ calculate synth_buf to pass to imdct_half -+ mov P_SB, a2 @ and keep a copy for ourselves -+ bic J_WRAP, lr, #63 @ mangled to make testing for wrap easier in inner loop -+ sub lr, lr, #32 -+ and lr, lr, #512-32 -+ str lr, [P_SB_OFF] @ rotate offset, modulo buffer size, ready for next call -+ ldr a3, [sp, #(16+6+2)*4] @ fetch in from stack, to pass to imdct_half -+VFP vmov s16, SCALE @ imdct_half is free to corrupt s0, but it contains one of our arguments in hardfp case -+ bl ff_imdct_half_c -+VFP vmov SCALE, s16 -+ -+ vmrs OLDFPSCR, FPSCR -+ ldr lr, =0x03030000 @ RunFast mode, short vectors of length 4, stride 1 -+ vmsr FPSCR, lr -+ ldr P_SB2_DN, [sp, #16*4] -+ ldr P_WIN_DN, [sp, #(16+6+0)*4] -+ ldr P_OUT_DN, [sp, #(16+6+1)*4] -+NOVFP vldr SCALE, [sp, #(16+6+3)*4] -+ -+#define IMM_OFF_SKEW 956 /* also valid immediate constant when you add 16*4 */ -+ add P_SB, P_SB, #IMM_OFF_SKEW @ so we can use -ve offsets to use full immediate offset range -+ add P_SB2_UP, P_SB2_DN, #16*4 -+ add P_WIN_UP, P_WIN_DN, #16*4+IMM_OFF_SKEW -+ add P_OUT_UP, P_OUT_DN, #16*4 -+ add P_SB2_DN, P_SB2_DN, #16*4 -+ add P_WIN_DN, P_WIN_DN, #12*4+IMM_OFF_SKEW -+ add P_OUT_DN, P_OUT_DN, #16*4 -+ mov I, #4 -+1: -+ vldmia P_SB2_UP!, {VB0-VB3} -+ vldmdb P_SB2_DN!, {VA0-VA3} -+ .set J, 512 - 64 -+ .set OFFSET, -IMM_OFF_SKEW -+ inner_loop ab,, head -+ .rept 7 -+ inner_loop ab, tail, head -+ .endr -+ inner_loop ab, tail -+ add P_WIN_UP, P_WIN_UP, #4*4 -+ sub P_WIN_DN, P_WIN_DN, #4*4 -+ vmul.f VB0, VB0, SCALE @ SCALE treated as scalar -+ add P_SB, P_SB, #(512+4)*4 -+ subs I, I, #1 -+ vmul.f VA0, VA0, SCALE -+ vstmia P_OUT_UP!, {VB0-VB3} -+ vstmdb P_OUT_DN!, {VA0-VA3} -+ bne 1b -+ -+ add P_SB2_DN, P_SB2_DN, #(16+28-12)*4 -+ sub P_SB2_UP, P_SB2_UP, #(16+16)*4 -+ add P_WIN_DN, P_WIN_DN, #(32+16+28-12)*4 -+ mov I, #4 -+1: -+ vldr.d d4, zero @ d4 = VC0 -+ vldr.d d5, zero -+ vldr.d d6, zero @ d6 = VD0 -+ vldr.d d7, zero -+ .set J, 512 - 64 -+ .set OFFSET, -IMM_OFF_SKEW -+ inner_loop cd,, head -+ .rept 7 -+ inner_loop cd, tail, head -+ .endr -+ inner_loop cd, tail -+ add P_WIN_UP, P_WIN_UP, #4*4 -+ sub P_WIN_DN, P_WIN_DN, #4*4 -+ add P_SB, P_SB, #(512+4)*4 -+ subs I, I, #1 -+ vstmia P_SB2_UP!, {VC0-VC3} -+ vstmdb P_SB2_DN!, {VD0-VD3} -+ bne 1b -+ -+ vmsr FPSCR, OLDFPSCR -+ vpop {s16-s31} -+ pop {r3-r7,pc} -+endfunc -+ -+ .align 3 -+zero: .word 0, 0 --- -1.8.1.6 - - -From d32ba2d8b8aacc9efb8c8a80152ae0684600e874 Mon Sep 17 00:00:00 2001 -From: Ben Avison -Date: Tue, 25 Jun 2013 17:22:50 +0100 -Subject: [PATCH 51/55] 1st version of ff_int32_to_float_fmul_scalar_vfp - ---- - libavcodec/arm/fmtconvert_init_arm.c | 10 +++++-- - libavcodec/arm/fmtconvert_vfp.S | 38 +++++++++++++++++++++++++ - 2 files changed, 46 insertions(+), 2 deletions(-) - -diff --git a/libavcodec/arm/fmtconvert_init_arm.c b/libavcodec/arm/fmtconvert_init_arm.c -index 4b6e393..6eb6cd4 100644 ---- a/libavcodec/arm/fmtconvert_init_arm.c -+++ b/libavcodec/arm/fmtconvert_init_arm.c -@@ -29,12 +29,18 @@ void ff_int32_to_float_fmul_scalar_neon(float *dst, const int *src, - void ff_float_to_int16_neon(int16_t *dst, const float *src, long len); - void ff_float_to_int16_interleave_neon(int16_t *, const float **, long, int); - -+void ff_int32_to_float_fmul_scalar_vfp(float *dst, const int *src, -+ float mul, int len); -+ - void ff_float_to_int16_vfp(int16_t *dst, const float *src, long len); - - void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx) - { -- if (HAVE_ARMVFP && HAVE_ARMV6) { -- c->float_to_int16 = ff_float_to_int16_vfp; -+ if (HAVE_ARMVFP) { -+ c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_vfp; -+ if (HAVE_ARMV6) { -+ c->float_to_int16 = ff_float_to_int16_vfp; -+ } - } - - if (HAVE_NEON) { -diff --git a/libavcodec/arm/fmtconvert_vfp.S b/libavcodec/arm/fmtconvert_vfp.S -index 7e2eb83..531a8ad 100644 ---- a/libavcodec/arm/fmtconvert_vfp.S -+++ b/libavcodec/arm/fmtconvert_vfp.S -@@ -1,5 +1,6 @@ - /* - * Copyright (c) 2008 Siarhei Siamashka -+ * Copyright (c) 2013 RISC OS Open Ltd - * - * This file is part of FFmpeg. - * -@@ -76,3 +77,40 @@ function ff_float_to_int16_vfp, export=1 - vpop {d8-d11} - pop {r4-r8,pc} - endfunc -+ -+/** -+ * ARM VFP optimised int32 to float conversion. -+ * Assume len is a multiple of 8, destination buffer is at least 4 bytes aligned -+ * (16 bytes alignment is best for BCM2835), little-endian. -+ */ -+@ void ff_int32_to_float_fmul_scalar_vfp(float *dst, const int *src, float mul, int len) -+function ff_int32_to_float_fmul_scalar_vfp, export=1 -+VFP tmp .req a4 -+VFP len .req a3 -+NOVFP tmp .req a3 -+NOVFP len .req a4 -+NOVFP vmov s0, a3 -+ ldr tmp, =0x03070000 @ RunFast mode, short vectors of length 8, stride 1 -+ vmrs ip, FPSCR -+ vmsr FPSCR, tmp -+1: -+ vldmia a2!, {s8-s15} -+ vcvt.f32.s32 s8, s8 -+ vcvt.f32.s32 s9, s9 -+ vcvt.f32.s32 s10, s10 -+ vcvt.f32.s32 s11, s11 -+ vcvt.f32.s32 s12, s12 -+ vcvt.f32.s32 s13, s13 -+ vcvt.f32.s32 s14, s14 -+ vcvt.f32.s32 s15, s15 -+ vmul.f32 s8, s8, s0 -+ subs len, len, #8 -+ vstmia a1!, {s8-s11} -+ vstmia a1!, {s12-s15} -+ bne 1b -+ -+ vmsr FPSCR, ip -+ bx lr -+endfunc -+ .unreq tmp -+ .unreq len --- -1.8.1.6 - - -From e8ba866ef0bb68e43da157683d398ab7cce817a6 Mon Sep 17 00:00:00 2001 -From: Ben Avison -Date: Wed, 26 Jun 2013 00:49:15 +0100 -Subject: [PATCH 52/55] 2nd version of fmul_scalar - ---- - libavcodec/arm/fmtconvert_init_arm.c | 5 + - libavcodec/arm/fmtconvert_vfp.S | 162 ++ - libavcodec/dcadec.c | 2533 +++++++++++++++++++++++ - libavcodec/fmtconvert.c | 7 + - libavcodec/fmtconvert.h | 14 + - 5 files changed, 2721 insertions(+) - create mode 100644 libavcodec/dcadec.c - -diff --git a/libavcodec/arm/fmtconvert_init_arm.c b/libavcodec/arm/fmtconvert_init_arm.c -index 6eb6cd4..91c652e 100644 ---- a/libavcodec/arm/fmtconvert_init_arm.c -+++ b/libavcodec/arm/fmtconvert_init_arm.c -@@ -31,6 +31,8 @@ void ff_int32_to_float_fmul_scalar_neon(float *dst, const int *src, - - void ff_int32_to_float_fmul_scalar_vfp(float *dst, const int *src, - float mul, int len); -+void ff_int32_to_float_fmul_scalar_array_vfp(FmtConvertContext *c, float *dst, const int *src, -+ float *mul, int len); - - void ff_float_to_int16_vfp(int16_t *dst, const float *src, long len); - -@@ -38,6 +40,9 @@ void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx) - { - if (HAVE_ARMVFP) { - c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_vfp; -+ if (!HAVE_NEON) { -+ c->int32_to_float_fmul_scalar_array = ff_int32_to_float_fmul_scalar_array_vfp; -+ } - if (HAVE_ARMV6) { - c->float_to_int16 = ff_float_to_int16_vfp; - } -diff --git a/libavcodec/arm/fmtconvert_vfp.S b/libavcodec/arm/fmtconvert_vfp.S -index 531a8ad..13f0bc0 100644 ---- a/libavcodec/arm/fmtconvert_vfp.S -+++ b/libavcodec/arm/fmtconvert_vfp.S -@@ -83,6 +83,168 @@ endfunc - * Assume len is a multiple of 8, destination buffer is at least 4 bytes aligned - * (16 bytes alignment is best for BCM2835), little-endian. - */ -+@ void ff_int32_to_float_fmul_scalar_array_vfp(if (FmtConvertContext *c, float *dst, const int *src, float *mul, int len) -+function ff_int32_to_float_fmul_scalar_array_vfp, export=1 -+ push {lr} -+ ldr a1, [sp, #4] -+ subs lr, a1, #3*8 -+ bcc 50f @ too short to pipeline -+ @ Now need to find (len / 8) % 3. The approximation -+ @ x / 24 = (x * 0xAB) >> 12 -+ @ is good for x < 4096, which is true for both AC3 and DCA. -+ mov a1, #0xAB -+ ldr ip, =0x03070000 @ RunFast mode, short vectors of length 8, stride 1 -+ mul a1, lr, a1 -+ vpush {s16-s31} -+ mov a1, a1, lsr #12 -+ add a1, a1, a1, lsl #1 -+ rsb a1, a1, lr, lsr #3 -+ cmp a1, #1 -+ vmrs a1, FPSCR -+ vmsr FPSCR, ip -+ beq 11f -+ blo 10f -+ @ Array is (2 + multiple of 3) x 8 floats long -+ @ drop through... -+ vldmia a3!, {s16-s23} -+ vldmia a4!, {s2,s3} -+ vldmia a3!, {s24-s31} -+ vcvt.f32.s32 s16, s16 -+ vcvt.f32.s32 s17, s17 -+ vcvt.f32.s32 s18, s18 -+ vcvt.f32.s32 s19, s19 -+ vcvt.f32.s32 s20, s20 -+ vcvt.f32.s32 s21, s21 -+ vcvt.f32.s32 s22, s22 -+ vcvt.f32.s32 s23, s23 -+ vmul.f32 s16, s16, s2 -+ @ drop through... -+3: -+ vldmia a3!, {s8-s15} -+ vldmia a4!, {s1} -+ vcvt.f32.s32 s24, s24 -+ vcvt.f32.s32 s25, s25 -+ vcvt.f32.s32 s26, s26 -+ vcvt.f32.s32 s27, s27 -+ vcvt.f32.s32 s28, s28 -+ vcvt.f32.s32 s29, s29 -+ vcvt.f32.s32 s30, s30 -+ vcvt.f32.s32 s31, s31 -+ vmul.f32 s24, s24, s3 -+ vstmia a2!, {s16-s19} -+ vstmia a2!, {s20-s23} -+2: -+ vldmia a3!, {s16-s23} -+ vldmia a4!, {s2} -+ vcvt.f32.s32 s8, s8 -+ vcvt.f32.s32 s9, s9 -+ vcvt.f32.s32 s10, s10 -+ vcvt.f32.s32 s11, s11 -+ vcvt.f32.s32 s12, s12 -+ vcvt.f32.s32 s13, s13 -+ vcvt.f32.s32 s14, s14 -+ vcvt.f32.s32 s15, s15 -+ vmul.f32 s8, s8, s1 -+ vstmia a2!, {s24-s27} -+ vstmia a2!, {s28-s31} -+1: -+ vldmia a3!, {s24-s31} -+ vldmia a4!, {s3} -+ vcvt.f32.s32 s16, s16 -+ vcvt.f32.s32 s17, s17 -+ vcvt.f32.s32 s18, s18 -+ vcvt.f32.s32 s19, s19 -+ vcvt.f32.s32 s20, s20 -+ vcvt.f32.s32 s21, s21 -+ vcvt.f32.s32 s22, s22 -+ vcvt.f32.s32 s23, s23 -+ vmul.f32 s16, s16, s2 -+ vstmia a2!, {s8-s11} -+ vstmia a2!, {s12-s15} -+ -+ subs lr, lr, #8*3 -+ bpl 3b -+ -+ vcvt.f32.s32 s24, s24 -+ vcvt.f32.s32 s25, s25 -+ vcvt.f32.s32 s26, s26 -+ vcvt.f32.s32 s27, s27 -+ vcvt.f32.s32 s28, s28 -+ vcvt.f32.s32 s29, s29 -+ vcvt.f32.s32 s30, s30 -+ vcvt.f32.s32 s31, s31 -+ vmul.f32 s24, s24, s3 -+ vstmia a2!, {s16-s19} -+ vstmia a2!, {s20-s23} -+ vstmia a2!, {s24-s27} -+ vstmia a2!, {s28-s31} -+ -+ vmsr FPSCR, a1 -+ vpop {s16-s31} -+ pop {pc} -+ -+10: @ Array is (multiple of 3) x 8 floats long -+ vldmia a3!, {s8-s15} -+ vldmia a4!, {s1,s2} -+ vldmia a3!, {s16-s23} -+ vcvt.f32.s32 s8, s8 -+ vcvt.f32.s32 s9, s9 -+ vcvt.f32.s32 s10, s10 -+ vcvt.f32.s32 s11, s11 -+ vcvt.f32.s32 s12, s12 -+ vcvt.f32.s32 s13, s13 -+ vcvt.f32.s32 s14, s14 -+ vcvt.f32.s32 s15, s15 -+ vmul.f32 s8, s8, s1 -+ b 1b -+ -+11: @ Array is (1 + multiple of 3) x 8 floats long -+ vldmia a3!, {s24-s31} -+ vldmia a4!, {s3} -+ vldmia a3!, {s8-s15} -+ vldmia a4!, {s1} -+ vcvt.f32.s32 s24, s24 -+ vcvt.f32.s32 s25, s25 -+ vcvt.f32.s32 s26, s26 -+ vcvt.f32.s32 s27, s27 -+ vcvt.f32.s32 s28, s28 -+ vcvt.f32.s32 s29, s29 -+ vcvt.f32.s32 s30, s30 -+ vcvt.f32.s32 s31, s31 -+ vmul.f32 s24, s24, s3 -+ b 2b -+ -+50: -+ ldr lr, =0x03070000 @ RunFast mode, short vectors of length 8, stride 1 -+ vmrs ip, FPSCR -+ vmsr FPSCR, lr -+51: -+ vldmia a3!, {s8-s15} -+ vldmia a4!, {s0} -+ vcvt.f32.s32 s8, s8 -+ vcvt.f32.s32 s9, s9 -+ vcvt.f32.s32 s10, s10 -+ vcvt.f32.s32 s11, s11 -+ vcvt.f32.s32 s12, s12 -+ vcvt.f32.s32 s13, s13 -+ vcvt.f32.s32 s14, s14 -+ vcvt.f32.s32 s15, s15 -+ vmul.f32 s8, s8, s0 -+ subs a1, a1, #8 -+ vstmia a2!, {s8-s11} -+ vstmia a2!, {s12-s15} -+ bne 51b -+ -+ vmsr FPSCR, ip -+ pop {pc} -+endfunc -+ -+/** -+ * ARM VFP optimised int32 to float conversion. -+ * Assume len is a multiple of 8, destination buffer is at least 4 bytes aligned -+ * (16 bytes alignment is best for BCM2835), little-endian. -+ * TODO: could be further optimised by unrolling and interleaving, as above -+ */ - @ void ff_int32_to_float_fmul_scalar_vfp(float *dst, const int *src, float mul, int len) - function ff_int32_to_float_fmul_scalar_vfp, export=1 - VFP tmp .req a4 -diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c -new file mode 100644 -index 0000000..fe568ee ---- /dev/null -+++ b/libavcodec/dcadec.c -@@ -0,0 +1,2533 @@ -+/* -+ * DCA compatible decoder -+ * Copyright (C) 2004 Gildas Bazin -+ * Copyright (C) 2004 Benjamin Zores -+ * Copyright (C) 2006 Benjamin Larsson -+ * Copyright (C) 2007 Konstantin Shishkov -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+ -+#include -+#include -+#include -+ -+#include "libavutil/channel_layout.h" -+#include "libavutil/common.h" -+#include "libavutil/float_dsp.h" -+#include "libavutil/internal.h" -+#include "libavutil/intreadwrite.h" -+#include "libavutil/mathematics.h" -+#include "libavutil/samplefmt.h" -+#include "avcodec.h" -+#include "fft.h" -+#include "get_bits.h" -+#include "put_bits.h" -+#include "dcadata.h" -+#include "dcahuff.h" -+#include "dca.h" -+#include "dca_parser.h" -+#include "mathops.h" -+#include "synth_filter.h" -+#include "dcadsp.h" -+#include "fmtconvert.h" -+#include "internal.h" -+ -+#if ARCH_ARM -+# include "arm/dca.h" -+#endif -+ -+//#define TRACE -+ -+#define DCA_PRIM_CHANNELS_MAX (7) -+#define DCA_SUBBANDS (64) -+#define DCA_ABITS_MAX (32) /* Should be 28 */ -+#define DCA_SUBSUBFRAMES_MAX (4) -+#define DCA_SUBFRAMES_MAX (16) -+#define DCA_BLOCKS_MAX (16) -+#define DCA_LFE_MAX (3) -+#define DCA_CHSETS_MAX (4) -+#define DCA_CHSET_CHANS_MAX (8) -+ -+enum DCAMode { -+ DCA_MONO = 0, -+ DCA_CHANNEL, -+ DCA_STEREO, -+ DCA_STEREO_SUMDIFF, -+ DCA_STEREO_TOTAL, -+ DCA_3F, -+ DCA_2F1R, -+ DCA_3F1R, -+ DCA_2F2R, -+ DCA_3F2R, -+ DCA_4F2R -+}; -+ -+/* these are unconfirmed but should be mostly correct */ -+enum DCAExSSSpeakerMask { -+ DCA_EXSS_FRONT_CENTER = 0x0001, -+ DCA_EXSS_FRONT_LEFT_RIGHT = 0x0002, -+ DCA_EXSS_SIDE_REAR_LEFT_RIGHT = 0x0004, -+ DCA_EXSS_LFE = 0x0008, -+ DCA_EXSS_REAR_CENTER = 0x0010, -+ DCA_EXSS_FRONT_HIGH_LEFT_RIGHT = 0x0020, -+ DCA_EXSS_REAR_LEFT_RIGHT = 0x0040, -+ DCA_EXSS_FRONT_HIGH_CENTER = 0x0080, -+ DCA_EXSS_OVERHEAD = 0x0100, -+ DCA_EXSS_CENTER_LEFT_RIGHT = 0x0200, -+ DCA_EXSS_WIDE_LEFT_RIGHT = 0x0400, -+ DCA_EXSS_SIDE_LEFT_RIGHT = 0x0800, -+ DCA_EXSS_LFE2 = 0x1000, -+ DCA_EXSS_SIDE_HIGH_LEFT_RIGHT = 0x2000, -+ DCA_EXSS_REAR_HIGH_CENTER = 0x4000, -+ DCA_EXSS_REAR_HIGH_LEFT_RIGHT = 0x8000, -+}; -+ -+enum DCAXxchSpeakerMask { -+ DCA_XXCH_FRONT_CENTER = 0x0000001, -+ DCA_XXCH_FRONT_LEFT = 0x0000002, -+ DCA_XXCH_FRONT_RIGHT = 0x0000004, -+ DCA_XXCH_SIDE_REAR_LEFT = 0x0000008, -+ DCA_XXCH_SIDE_REAR_RIGHT = 0x0000010, -+ DCA_XXCH_LFE1 = 0x0000020, -+ DCA_XXCH_REAR_CENTER = 0x0000040, -+ DCA_XXCH_SURROUND_REAR_LEFT = 0x0000080, -+ DCA_XXCH_SURROUND_REAR_RIGHT = 0x0000100, -+ DCA_XXCH_SIDE_SURROUND_LEFT = 0x0000200, -+ DCA_XXCH_SIDE_SURROUND_RIGHT = 0x0000400, -+ DCA_XXCH_FRONT_CENTER_LEFT = 0x0000800, -+ DCA_XXCH_FRONT_CENTER_RIGHT = 0x0001000, -+ DCA_XXCH_FRONT_HIGH_LEFT = 0x0002000, -+ DCA_XXCH_FRONT_HIGH_CENTER = 0x0004000, -+ DCA_XXCH_FRONT_HIGH_RIGHT = 0x0008000, -+ DCA_XXCH_LFE2 = 0x0010000, -+ DCA_XXCH_SIDE_FRONT_LEFT = 0x0020000, -+ DCA_XXCH_SIDE_FRONT_RIGHT = 0x0040000, -+ DCA_XXCH_OVERHEAD = 0x0080000, -+ DCA_XXCH_SIDE_HIGH_LEFT = 0x0100000, -+ DCA_XXCH_SIDE_HIGH_RIGHT = 0x0200000, -+ DCA_XXCH_REAR_HIGH_CENTER = 0x0400000, -+ DCA_XXCH_REAR_HIGH_LEFT = 0x0800000, -+ DCA_XXCH_REAR_HIGH_RIGHT = 0x1000000, -+ DCA_XXCH_REAR_LOW_CENTER = 0x2000000, -+ DCA_XXCH_REAR_LOW_LEFT = 0x4000000, -+ DCA_XXCH_REAR_LOW_RIGHT = 0x8000000, -+}; -+ -+static const uint32_t map_xxch_to_native[28] = { -+ AV_CH_FRONT_CENTER, -+ AV_CH_FRONT_LEFT, -+ AV_CH_FRONT_RIGHT, -+ AV_CH_SIDE_LEFT, -+ AV_CH_SIDE_RIGHT, -+ AV_CH_LOW_FREQUENCY, -+ AV_CH_BACK_CENTER, -+ AV_CH_BACK_LEFT, -+ AV_CH_BACK_RIGHT, -+ AV_CH_SIDE_LEFT, /* side surround left -- dup sur side L */ -+ AV_CH_SIDE_RIGHT, /* side surround right -- dup sur side R */ -+ AV_CH_FRONT_LEFT_OF_CENTER, -+ AV_CH_FRONT_RIGHT_OF_CENTER, -+ AV_CH_TOP_FRONT_LEFT, -+ AV_CH_TOP_FRONT_CENTER, -+ AV_CH_TOP_FRONT_RIGHT, -+ AV_CH_LOW_FREQUENCY, /* lfe2 -- duplicate lfe1 position */ -+ AV_CH_FRONT_LEFT_OF_CENTER, /* side front left -- dup front cntr L */ -+ AV_CH_FRONT_RIGHT_OF_CENTER,/* side front right -- dup front cntr R */ -+ AV_CH_TOP_CENTER, /* overhead */ -+ AV_CH_TOP_FRONT_LEFT, /* side high left -- dup */ -+ AV_CH_TOP_FRONT_RIGHT, /* side high right -- dup */ -+ AV_CH_TOP_BACK_CENTER, -+ AV_CH_TOP_BACK_LEFT, -+ AV_CH_TOP_BACK_RIGHT, -+ AV_CH_BACK_CENTER, /* rear low center -- dup */ -+ AV_CH_BACK_LEFT, /* rear low left -- dup */ -+ AV_CH_BACK_RIGHT /* read low right -- dup */ -+}; -+ -+enum DCAExtensionMask { -+ DCA_EXT_CORE = 0x001, ///< core in core substream -+ DCA_EXT_XXCH = 0x002, ///< XXCh channels extension in core substream -+ DCA_EXT_X96 = 0x004, ///< 96/24 extension in core substream -+ DCA_EXT_XCH = 0x008, ///< XCh channel extension in core substream -+ DCA_EXT_EXSS_CORE = 0x010, ///< core in ExSS (extension substream) -+ DCA_EXT_EXSS_XBR = 0x020, ///< extended bitrate extension in ExSS -+ DCA_EXT_EXSS_XXCH = 0x040, ///< XXCh channels extension in ExSS -+ DCA_EXT_EXSS_X96 = 0x080, ///< 96/24 extension in ExSS -+ DCA_EXT_EXSS_LBR = 0x100, ///< low bitrate component in ExSS -+ DCA_EXT_EXSS_XLL = 0x200, ///< lossless extension in ExSS -+}; -+ -+/* -1 are reserved or unknown */ -+static const int dca_ext_audio_descr_mask[] = { -+ DCA_EXT_XCH, -+ -1, -+ DCA_EXT_X96, -+ DCA_EXT_XCH | DCA_EXT_X96, -+ -1, -+ -1, -+ DCA_EXT_XXCH, -+ -1, -+}; -+ -+/* extensions that reside in core substream */ -+#define DCA_CORE_EXTS (DCA_EXT_XCH | DCA_EXT_XXCH | DCA_EXT_X96) -+ -+/* Tables for mapping dts channel configurations to libavcodec multichannel api. -+ * Some compromises have been made for special configurations. Most configurations -+ * are never used so complete accuracy is not needed. -+ * -+ * L = left, R = right, C = center, S = surround, F = front, R = rear, T = total, OV = overhead. -+ * S -> side, when both rear and back are configured move one of them to the side channel -+ * OV -> center back -+ * All 2 channel configurations -> AV_CH_LAYOUT_STEREO -+ */ -+static const uint64_t dca_core_channel_layout[] = { -+ AV_CH_FRONT_CENTER, ///< 1, A -+ AV_CH_LAYOUT_STEREO, ///< 2, A + B (dual mono) -+ AV_CH_LAYOUT_STEREO, ///< 2, L + R (stereo) -+ AV_CH_LAYOUT_STEREO, ///< 2, (L + R) + (L - R) (sum-difference) -+ AV_CH_LAYOUT_STEREO, ///< 2, LT + RT (left and right total) -+ AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER, ///< 3, C + L + R -+ AV_CH_LAYOUT_STEREO | AV_CH_BACK_CENTER, ///< 3, L + R + S -+ AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER | AV_CH_BACK_CENTER, ///< 4, C + L + R + S -+ AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT, ///< 4, L + R + SL + SR -+ -+ AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER | AV_CH_SIDE_LEFT | -+ AV_CH_SIDE_RIGHT, ///< 5, C + L + R + SL + SR -+ -+ AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT | -+ AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR -+ -+ AV_CH_LAYOUT_STEREO | AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT | -+ AV_CH_FRONT_CENTER | AV_CH_BACK_CENTER, ///< 6, C + L + R + LR + RR + OV -+ -+ AV_CH_FRONT_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER | -+ AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_BACK_CENTER | -+ AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT, ///< 6, CF + CR + LF + RF + LR + RR -+ -+ AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_CENTER | -+ AV_CH_FRONT_RIGHT_OF_CENTER | AV_CH_LAYOUT_STEREO | -+ AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR -+ -+ AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER | -+ AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT | -+ AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2 + SR1 + SR2 -+ -+ AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_CENTER | -+ AV_CH_FRONT_RIGHT_OF_CENTER | AV_CH_LAYOUT_STEREO | -+ AV_CH_SIDE_LEFT | AV_CH_BACK_CENTER | AV_CH_SIDE_RIGHT, ///< 8, CL + C + CR + L + R + SL + S + SR -+}; -+ -+static const int8_t dca_lfe_index[] = { -+ 1, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 1, 3, 2, 3 -+}; -+ -+static const int8_t dca_channel_reorder_lfe[][9] = { -+ { 0, -1, -1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, -1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, -1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, -1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, -1, -1, -1, -1, -1, -1, -1}, -+ { 2, 0, 1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, 3, -1, -1, -1, -1, -1, -1}, -+ { 2, 0, 1, 4, -1, -1, -1, -1, -1}, -+ { 0, 1, 3, 4, -1, -1, -1, -1, -1}, -+ { 2, 0, 1, 4, 5, -1, -1, -1, -1}, -+ { 3, 4, 0, 1, 5, 6, -1, -1, -1}, -+ { 2, 0, 1, 4, 5, 6, -1, -1, -1}, -+ { 0, 6, 4, 5, 2, 3, -1, -1, -1}, -+ { 4, 2, 5, 0, 1, 6, 7, -1, -1}, -+ { 5, 6, 0, 1, 7, 3, 8, 4, -1}, -+ { 4, 2, 5, 0, 1, 6, 8, 7, -1}, -+}; -+ -+static const int8_t dca_channel_reorder_lfe_xch[][9] = { -+ { 0, 2, -1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, 3, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, 3, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, 3, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, 3, -1, -1, -1, -1, -1, -1}, -+ { 2, 0, 1, 4, -1, -1, -1, -1, -1}, -+ { 0, 1, 3, 4, -1, -1, -1, -1, -1}, -+ { 2, 0, 1, 4, 5, -1, -1, -1, -1}, -+ { 0, 1, 4, 5, 3, -1, -1, -1, -1}, -+ { 2, 0, 1, 5, 6, 4, -1, -1, -1}, -+ { 3, 4, 0, 1, 6, 7, 5, -1, -1}, -+ { 2, 0, 1, 4, 5, 6, 7, -1, -1}, -+ { 0, 6, 4, 5, 2, 3, 7, -1, -1}, -+ { 4, 2, 5, 0, 1, 7, 8, 6, -1}, -+ { 5, 6, 0, 1, 8, 3, 9, 4, 7}, -+ { 4, 2, 5, 0, 1, 6, 9, 8, 7}, -+}; -+ -+static const int8_t dca_channel_reorder_nolfe[][9] = { -+ { 0, -1, -1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, -1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, -1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, -1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, -1, -1, -1, -1, -1, -1, -1}, -+ { 2, 0, 1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, 2, -1, -1, -1, -1, -1, -1}, -+ { 2, 0, 1, 3, -1, -1, -1, -1, -1}, -+ { 0, 1, 2, 3, -1, -1, -1, -1, -1}, -+ { 2, 0, 1, 3, 4, -1, -1, -1, -1}, -+ { 2, 3, 0, 1, 4, 5, -1, -1, -1}, -+ { 2, 0, 1, 3, 4, 5, -1, -1, -1}, -+ { 0, 5, 3, 4, 1, 2, -1, -1, -1}, -+ { 3, 2, 4, 0, 1, 5, 6, -1, -1}, -+ { 4, 5, 0, 1, 6, 2, 7, 3, -1}, -+ { 3, 2, 4, 0, 1, 5, 7, 6, -1}, -+}; -+ -+static const int8_t dca_channel_reorder_nolfe_xch[][9] = { -+ { 0, 1, -1, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, 2, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, 2, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, 2, -1, -1, -1, -1, -1, -1}, -+ { 0, 1, 2, -1, -1, -1, -1, -1, -1}, -+ { 2, 0, 1, 3, -1, -1, -1, -1, -1}, -+ { 0, 1, 2, 3, -1, -1, -1, -1, -1}, -+ { 2, 0, 1, 3, 4, -1, -1, -1, -1}, -+ { 0, 1, 3, 4, 2, -1, -1, -1, -1}, -+ { 2, 0, 1, 4, 5, 3, -1, -1, -1}, -+ { 2, 3, 0, 1, 5, 6, 4, -1, -1}, -+ { 2, 0, 1, 3, 4, 5, 6, -1, -1}, -+ { 0, 5, 3, 4, 1, 2, 6, -1, -1}, -+ { 3, 2, 4, 0, 1, 6, 7, 5, -1}, -+ { 4, 5, 0, 1, 7, 2, 8, 3, 6}, -+ { 3, 2, 4, 0, 1, 5, 8, 7, 6}, -+}; -+ -+#define DCA_DOLBY 101 /* FIXME */ -+ -+#define DCA_CHANNEL_BITS 6 -+#define DCA_CHANNEL_MASK 0x3F -+ -+#define DCA_LFE 0x80 -+ -+#define HEADER_SIZE 14 -+ -+#define DCA_MAX_FRAME_SIZE 16384 -+#define DCA_MAX_EXSS_HEADER_SIZE 4096 -+ -+#define DCA_BUFFER_PADDING_SIZE 1024 -+ -+/** Bit allocation */ -+typedef struct { -+ int offset; ///< code values offset -+ int maxbits[8]; ///< max bits in VLC -+ int wrap; ///< wrap for get_vlc2() -+ VLC vlc[8]; ///< actual codes -+} BitAlloc; -+ -+static BitAlloc dca_bitalloc_index; ///< indexes for samples VLC select -+static BitAlloc dca_tmode; ///< transition mode VLCs -+static BitAlloc dca_scalefactor; ///< scalefactor VLCs -+static BitAlloc dca_smpl_bitalloc[11]; ///< samples VLCs -+ -+static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, -+ int idx) -+{ -+ return get_vlc2(gb, ba->vlc[idx].table, ba->vlc[idx].bits, ba->wrap) + -+ ba->offset; -+} -+ -+typedef struct { -+ AVCodecContext *avctx; -+ /* Frame header */ -+ int frame_type; ///< type of the current frame -+ int samples_deficit; ///< deficit sample count -+ int crc_present; ///< crc is present in the bitstream -+ int sample_blocks; ///< number of PCM sample blocks -+ int frame_size; ///< primary frame byte size -+ int amode; ///< audio channels arrangement -+ int sample_rate; ///< audio sampling rate -+ int bit_rate; ///< transmission bit rate -+ int bit_rate_index; ///< transmission bit rate index -+ -+ int downmix; ///< embedded downmix enabled -+ int dynrange; ///< embedded dynamic range flag -+ int timestamp; ///< embedded time stamp flag -+ int aux_data; ///< auxiliary data flag -+ int hdcd; ///< source material is mastered in HDCD -+ int ext_descr; ///< extension audio descriptor flag -+ int ext_coding; ///< extended coding flag -+ int aspf; ///< audio sync word insertion flag -+ int lfe; ///< low frequency effects flag -+ int predictor_history; ///< predictor history flag -+ int header_crc; ///< header crc check bytes -+ int multirate_inter; ///< multirate interpolator switch -+ int version; ///< encoder software revision -+ int copy_history; ///< copy history -+ int source_pcm_res; ///< source pcm resolution -+ int front_sum; ///< front sum/difference flag -+ int surround_sum; ///< surround sum/difference flag -+ int dialog_norm; ///< dialog normalisation parameter -+ -+ /* Primary audio coding header */ -+ int subframes; ///< number of subframes -+ int total_channels; ///< number of channels including extensions -+ int prim_channels; ///< number of primary audio channels -+ int subband_activity[DCA_PRIM_CHANNELS_MAX]; ///< subband activity count -+ int vq_start_subband[DCA_PRIM_CHANNELS_MAX]; ///< high frequency vq start subband -+ int joint_intensity[DCA_PRIM_CHANNELS_MAX]; ///< joint intensity coding index -+ int transient_huffman[DCA_PRIM_CHANNELS_MAX]; ///< transient mode code book -+ int scalefactor_huffman[DCA_PRIM_CHANNELS_MAX]; ///< scale factor code book -+ int bitalloc_huffman[DCA_PRIM_CHANNELS_MAX]; ///< bit allocation quantizer select -+ int quant_index_huffman[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< quantization index codebook select -+ float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< scale factor adjustment -+ -+ /* Primary audio coding side information */ -+ int subsubframes[DCA_SUBFRAMES_MAX]; ///< number of subsubframes -+ int partial_samples[DCA_SUBFRAMES_MAX]; ///< partial subsubframe samples count -+ int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction mode (ADPCM used or not) -+ int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction VQ coefs -+ int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< bit allocation index -+ int transition_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< transition mode (transients) -+ int scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][2]; ///< scale factors (2 if transient) -+ int joint_huff[DCA_PRIM_CHANNELS_MAX]; ///< joint subband scale factors codebook -+ int joint_scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< joint subband scale factors -+ int downmix_coef[DCA_PRIM_CHANNELS_MAX][2]; ///< stereo downmix coefficients -+ int dynrange_coef; ///< dynamic range coefficient -+ -+ int high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< VQ encoded high frequency subbands -+ -+ float lfe_data[2 * DCA_LFE_MAX * (DCA_BLOCKS_MAX + 4)]; ///< Low frequency effect data -+ int lfe_scale_factor; -+ -+ /* Subband samples history (for ADPCM) */ -+ DECLARE_ALIGNED(16, float, subband_samples_hist)[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][4]; -+ DECLARE_ALIGNED(32, float, subband_fir_hist)[DCA_PRIM_CHANNELS_MAX][512]; -+ DECLARE_ALIGNED(32, float, subband_fir_noidea)[DCA_PRIM_CHANNELS_MAX][32]; -+ int hist_index[DCA_PRIM_CHANNELS_MAX]; -+ DECLARE_ALIGNED(32, float, raXin)[32]; -+ -+ int output; ///< type of output -+ -+ DECLARE_ALIGNED(32, float, subband_samples)[DCA_BLOCKS_MAX][DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8]; -+ float *samples_chanptr[DCA_PRIM_CHANNELS_MAX + 1]; -+ float *extra_channels[DCA_PRIM_CHANNELS_MAX + 1]; -+ uint8_t *extra_channels_buffer; -+ unsigned int extra_channels_buffer_size; -+ -+ uint8_t dca_buffer[DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE + DCA_BUFFER_PADDING_SIZE]; -+ int dca_buffer_size; ///< how much data is in the dca_buffer -+ -+ const int8_t *channel_order_tab; ///< channel reordering table, lfe and non lfe -+ GetBitContext gb; -+ /* Current position in DCA frame */ -+ int current_subframe; -+ int current_subsubframe; -+ -+ int core_ext_mask; ///< present extensions in the core substream -+ -+ /* XCh extension information */ -+ int xch_present; ///< XCh extension present and valid -+ int xch_base_channel; ///< index of first (only) channel containing XCH data -+ -+ /* XXCH extension information */ -+ int xxch_chset; -+ int xxch_nbits_spk_mask; -+ uint32_t xxch_core_spkmask; -+ uint32_t xxch_spk_masks[4]; /* speaker masks, last element is core mask */ -+ int xxch_chset_nch[4]; -+ float xxch_dmix_sf[DCA_CHSETS_MAX]; -+ -+ uint32_t xxch_dmix_embedded; /* lower layer has mix pre-embedded, per chset */ -+ float xxch_dmix_coeff[DCA_PRIM_CHANNELS_MAX][32]; /* worst case sizing */ -+ -+ int8_t xxch_order_tab[32]; -+ int8_t lfe_index; -+ -+ /* ExSS header parser */ -+ int static_fields; ///< static fields present -+ int mix_metadata; ///< mixing metadata present -+ int num_mix_configs; ///< number of mix out configurations -+ int mix_config_num_ch[4]; ///< number of channels in each mix out configuration -+ -+ int profile; -+ -+ int debug_flag; ///< used for suppressing repeated error messages output -+ AVFloatDSPContext fdsp; -+ FFTContext imdct; -+ SynthFilterContext synth; -+ DCADSPContext dcadsp; -+ FmtConvertContext fmt_conv; -+} DCAContext; -+ -+static const uint16_t dca_vlc_offs[] = { -+ 0, 512, 640, 768, 1282, 1794, 2436, 3080, 3770, 4454, 5364, -+ 5372, 5380, 5388, 5392, 5396, 5412, 5420, 5428, 5460, 5492, 5508, -+ 5572, 5604, 5668, 5796, 5860, 5892, 6412, 6668, 6796, 7308, 7564, -+ 7820, 8076, 8620, 9132, 9388, 9910, 10166, 10680, 11196, 11726, 12240, -+ 12752, 13298, 13810, 14326, 14840, 15500, 16022, 16540, 17158, 17678, 18264, -+ 18796, 19352, 19926, 20468, 21472, 22398, 23014, 23622, -+}; -+ -+static av_cold void dca_init_vlcs(void) -+{ -+ static int vlcs_initialized = 0; -+ int i, j, c = 14; -+ static VLC_TYPE dca_table[23622][2]; -+ -+ if (vlcs_initialized) -+ return; -+ -+ dca_bitalloc_index.offset = 1; -+ dca_bitalloc_index.wrap = 2; -+ for (i = 0; i < 5; i++) { -+ dca_bitalloc_index.vlc[i].table = &dca_table[dca_vlc_offs[i]]; -+ dca_bitalloc_index.vlc[i].table_allocated = dca_vlc_offs[i + 1] - dca_vlc_offs[i]; -+ init_vlc(&dca_bitalloc_index.vlc[i], bitalloc_12_vlc_bits[i], 12, -+ bitalloc_12_bits[i], 1, 1, -+ bitalloc_12_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); -+ } -+ dca_scalefactor.offset = -64; -+ dca_scalefactor.wrap = 2; -+ for (i = 0; i < 5; i++) { -+ dca_scalefactor.vlc[i].table = &dca_table[dca_vlc_offs[i + 5]]; -+ dca_scalefactor.vlc[i].table_allocated = dca_vlc_offs[i + 6] - dca_vlc_offs[i + 5]; -+ init_vlc(&dca_scalefactor.vlc[i], SCALES_VLC_BITS, 129, -+ scales_bits[i], 1, 1, -+ scales_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); -+ } -+ dca_tmode.offset = 0; -+ dca_tmode.wrap = 1; -+ for (i = 0; i < 4; i++) { -+ dca_tmode.vlc[i].table = &dca_table[dca_vlc_offs[i + 10]]; -+ dca_tmode.vlc[i].table_allocated = dca_vlc_offs[i + 11] - dca_vlc_offs[i + 10]; -+ init_vlc(&dca_tmode.vlc[i], tmode_vlc_bits[i], 4, -+ tmode_bits[i], 1, 1, -+ tmode_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); -+ } -+ -+ for (i = 0; i < 10; i++) -+ for (j = 0; j < 7; j++) { -+ if (!bitalloc_codes[i][j]) -+ break; -+ dca_smpl_bitalloc[i + 1].offset = bitalloc_offsets[i]; -+ dca_smpl_bitalloc[i + 1].wrap = 1 + (j > 4); -+ dca_smpl_bitalloc[i + 1].vlc[j].table = &dca_table[dca_vlc_offs[c]]; -+ dca_smpl_bitalloc[i + 1].vlc[j].table_allocated = dca_vlc_offs[c + 1] - dca_vlc_offs[c]; -+ -+ init_vlc(&dca_smpl_bitalloc[i + 1].vlc[j], bitalloc_maxbits[i][j], -+ bitalloc_sizes[i], -+ bitalloc_bits[i][j], 1, 1, -+ bitalloc_codes[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC); -+ c++; -+ } -+ vlcs_initialized = 1; -+} -+ -+static inline void get_array(GetBitContext *gb, int *dst, int len, int bits) -+{ -+ while (len--) -+ *dst++ = get_bits(gb, bits); -+} -+ -+static inline int dca_xxch2index(DCAContext *s, int xxch_ch) -+{ -+ int i, base, mask; -+ -+ /* locate channel set containing the channel */ -+ for (i = -1, base = 0, mask = (s->xxch_core_spkmask & ~DCA_XXCH_LFE1); -+ i <= s->xxch_chset && !(mask & xxch_ch); mask = s->xxch_spk_masks[++i]) -+ base += av_popcount(mask); -+ -+ return base + av_popcount(mask & (xxch_ch - 1)); -+} -+ -+static int dca_parse_audio_coding_header(DCAContext *s, int base_channel, -+ int xxch) -+{ -+ int i, j; -+ static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 }; -+ static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }; -+ static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 }; -+ int hdr_pos = 0, hdr_size = 0; -+ float sign, mag, scale_factor; -+ int this_chans, acc_mask; -+ int embedded_downmix; -+ int nchans, mask[8]; -+ int coeff, ichan; -+ -+ /* xxch has arbitrary sized audio coding headers */ -+ if (xxch) { -+ hdr_pos = get_bits_count(&s->gb); -+ hdr_size = get_bits(&s->gb, 7) + 1; -+ } -+ -+ nchans = get_bits(&s->gb, 3) + 1; -+ s->total_channels = nchans + base_channel; -+ s->prim_channels = s->total_channels; -+ -+ /* obtain speaker layout mask & downmix coefficients for XXCH */ -+ if (xxch) { -+ acc_mask = s->xxch_core_spkmask; -+ -+ this_chans = get_bits(&s->gb, s->xxch_nbits_spk_mask - 6) << 6; -+ s->xxch_spk_masks[s->xxch_chset] = this_chans; -+ s->xxch_chset_nch[s->xxch_chset] = nchans; -+ -+ for (i = 0; i <= s->xxch_chset; i++) -+ acc_mask |= s->xxch_spk_masks[i]; -+ -+ /* check for downmixing information */ -+ if (get_bits1(&s->gb)) { -+ embedded_downmix = get_bits1(&s->gb); -+ scale_factor = -+ 1.0f / dca_downmix_scale_factors[(get_bits(&s->gb, 6) - 1) << 2]; -+ -+ s->xxch_dmix_sf[s->xxch_chset] = scale_factor; -+ -+ for (i = base_channel; i < s->prim_channels; i++) { -+ mask[i] = get_bits(&s->gb, s->xxch_nbits_spk_mask); -+ } -+ -+ for (j = base_channel; j < s->prim_channels; j++) { -+ memset(s->xxch_dmix_coeff[j], 0, sizeof(s->xxch_dmix_coeff[0])); -+ s->xxch_dmix_embedded |= (embedded_downmix << j); -+ for (i = 0; i < s->xxch_nbits_spk_mask; i++) { -+ if (mask[j] & (1 << i)) { -+ if ((1 << i) == DCA_XXCH_LFE1) { -+ av_log(s->avctx, AV_LOG_WARNING, -+ "DCA-XXCH: dmix to LFE1 not supported.\n"); -+ continue; -+ } -+ -+ coeff = get_bits(&s->gb, 7); -+ sign = (coeff & 64) ? 1.0 : -1.0; -+ mag = dca_downmix_scale_factors[((coeff & 63) - 1) << 2]; -+ ichan = dca_xxch2index(s, 1 << i); -+ s->xxch_dmix_coeff[j][ichan] = sign * mag; -+ } -+ } -+ } -+ } -+ } -+ -+ if (s->prim_channels > DCA_PRIM_CHANNELS_MAX) -+ s->prim_channels = DCA_PRIM_CHANNELS_MAX; -+ -+ -+ for (i = base_channel; i < s->prim_channels; i++) { -+ s->subband_activity[i] = get_bits(&s->gb, 5) + 2; -+ if (s->subband_activity[i] > DCA_SUBBANDS) -+ s->subband_activity[i] = DCA_SUBBANDS; -+ } -+ for (i = base_channel; i < s->prim_channels; i++) { -+ s->vq_start_subband[i] = get_bits(&s->gb, 5) + 1; -+ if (s->vq_start_subband[i] > DCA_SUBBANDS) -+ s->vq_start_subband[i] = DCA_SUBBANDS; -+ } -+ get_array(&s->gb, s->joint_intensity + base_channel, s->prim_channels - base_channel, 3); -+ get_array(&s->gb, s->transient_huffman + base_channel, s->prim_channels - base_channel, 2); -+ get_array(&s->gb, s->scalefactor_huffman + base_channel, s->prim_channels - base_channel, 3); -+ get_array(&s->gb, s->bitalloc_huffman + base_channel, s->prim_channels - base_channel, 3); -+ -+ /* Get codebooks quantization indexes */ -+ if (!base_channel) -+ memset(s->quant_index_huffman, 0, sizeof(s->quant_index_huffman)); -+ for (j = 1; j < 11; j++) -+ for (i = base_channel; i < s->prim_channels; i++) -+ s->quant_index_huffman[i][j] = get_bits(&s->gb, bitlen[j]); -+ -+ /* Get scale factor adjustment */ -+ for (j = 0; j < 11; j++) -+ for (i = base_channel; i < s->prim_channels; i++) -+ s->scalefactor_adj[i][j] = 1; -+ -+ for (j = 1; j < 11; j++) -+ for (i = base_channel; i < s->prim_channels; i++) -+ if (s->quant_index_huffman[i][j] < thr[j]) -+ s->scalefactor_adj[i][j] = adj_table[get_bits(&s->gb, 2)]; -+ -+ if (!xxch) { -+ if (s->crc_present) { -+ /* Audio header CRC check */ -+ get_bits(&s->gb, 16); -+ } -+ } else { -+ /* Skip to the end of the header, also ignore CRC if present */ -+ i = get_bits_count(&s->gb); -+ if (hdr_pos + 8 * hdr_size > i) -+ skip_bits_long(&s->gb, hdr_pos + 8 * hdr_size - i); -+ } -+ -+ s->current_subframe = 0; -+ s->current_subsubframe = 0; -+ -+#ifdef TRACE -+ av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes); -+ av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\n", s->prim_channels); -+ for (i = base_channel; i < s->prim_channels; i++) { -+ av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n", -+ s->subband_activity[i]); -+ av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n", -+ s->vq_start_subband[i]); -+ av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n", -+ s->joint_intensity[i]); -+ av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n", -+ s->transient_huffman[i]); -+ av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n", -+ s->scalefactor_huffman[i]); -+ av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n", -+ s->bitalloc_huffman[i]); -+ av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:"); -+ for (j = 0; j < 11; j++) -+ av_log(s->avctx, AV_LOG_DEBUG, " %i", s->quant_index_huffman[i][j]); -+ av_log(s->avctx, AV_LOG_DEBUG, "\n"); -+ av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:"); -+ for (j = 0; j < 11; j++) -+ av_log(s->avctx, AV_LOG_DEBUG, " %1.3f", s->scalefactor_adj[i][j]); -+ av_log(s->avctx, AV_LOG_DEBUG, "\n"); -+ } -+#endif -+ -+ return 0; -+} -+ -+static int dca_parse_frame_header(DCAContext *s) -+{ -+ init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8); -+ -+ /* Sync code */ -+ skip_bits_long(&s->gb, 32); -+ -+ /* Frame header */ -+ s->frame_type = get_bits(&s->gb, 1); -+ s->samples_deficit = get_bits(&s->gb, 5) + 1; -+ s->crc_present = get_bits(&s->gb, 1); -+ s->sample_blocks = get_bits(&s->gb, 7) + 1; -+ s->frame_size = get_bits(&s->gb, 14) + 1; -+ if (s->frame_size < 95) -+ return AVERROR_INVALIDDATA; -+ s->amode = get_bits(&s->gb, 6); -+ s->sample_rate = avpriv_dca_sample_rates[get_bits(&s->gb, 4)]; -+ if (!s->sample_rate) -+ return AVERROR_INVALIDDATA; -+ s->bit_rate_index = get_bits(&s->gb, 5); -+ s->bit_rate = dca_bit_rates[s->bit_rate_index]; -+ if (!s->bit_rate) -+ return AVERROR_INVALIDDATA; -+ -+ s->downmix = get_bits(&s->gb, 1); /* note: this is FixedBit == 0 */ -+ s->dynrange = get_bits(&s->gb, 1); -+ s->timestamp = get_bits(&s->gb, 1); -+ s->aux_data = get_bits(&s->gb, 1); -+ s->hdcd = get_bits(&s->gb, 1); -+ s->ext_descr = get_bits(&s->gb, 3); -+ s->ext_coding = get_bits(&s->gb, 1); -+ s->aspf = get_bits(&s->gb, 1); -+ s->lfe = get_bits(&s->gb, 2); -+ s->predictor_history = get_bits(&s->gb, 1); -+ -+ if (s->lfe == 3) { -+ s->lfe = 0; -+ av_log_ask_for_sample(s->avctx, "LFE is 3\n"); -+ return AVERROR_PATCHWELCOME; -+ } -+ -+ /* TODO: check CRC */ -+ if (s->crc_present) -+ s->header_crc = get_bits(&s->gb, 16); -+ -+ s->multirate_inter = get_bits(&s->gb, 1); -+ s->version = get_bits(&s->gb, 4); -+ s->copy_history = get_bits(&s->gb, 2); -+ s->source_pcm_res = get_bits(&s->gb, 3); -+ s->front_sum = get_bits(&s->gb, 1); -+ s->surround_sum = get_bits(&s->gb, 1); -+ s->dialog_norm = get_bits(&s->gb, 4); -+ -+ /* FIXME: channels mixing levels */ -+ s->output = s->amode; -+ if (s->lfe) -+ s->output |= DCA_LFE; -+ -+#ifdef TRACE -+ av_log(s->avctx, AV_LOG_DEBUG, "frame type: %i\n", s->frame_type); -+ av_log(s->avctx, AV_LOG_DEBUG, "samples deficit: %i\n", s->samples_deficit); -+ av_log(s->avctx, AV_LOG_DEBUG, "crc present: %i\n", s->crc_present); -+ av_log(s->avctx, AV_LOG_DEBUG, "sample blocks: %i (%i samples)\n", -+ s->sample_blocks, s->sample_blocks * 32); -+ av_log(s->avctx, AV_LOG_DEBUG, "frame size: %i bytes\n", s->frame_size); -+ av_log(s->avctx, AV_LOG_DEBUG, "amode: %i (%i channels)\n", -+ s->amode, dca_channels[s->amode]); -+ av_log(s->avctx, AV_LOG_DEBUG, "sample rate: %i Hz\n", -+ s->sample_rate); -+ av_log(s->avctx, AV_LOG_DEBUG, "bit rate: %i bits/s\n", -+ s->bit_rate); -+ av_log(s->avctx, AV_LOG_DEBUG, "downmix: %i\n", s->downmix); -+ av_log(s->avctx, AV_LOG_DEBUG, "dynrange: %i\n", s->dynrange); -+ av_log(s->avctx, AV_LOG_DEBUG, "timestamp: %i\n", s->timestamp); -+ av_log(s->avctx, AV_LOG_DEBUG, "aux_data: %i\n", s->aux_data); -+ av_log(s->avctx, AV_LOG_DEBUG, "hdcd: %i\n", s->hdcd); -+ av_log(s->avctx, AV_LOG_DEBUG, "ext descr: %i\n", s->ext_descr); -+ av_log(s->avctx, AV_LOG_DEBUG, "ext coding: %i\n", s->ext_coding); -+ av_log(s->avctx, AV_LOG_DEBUG, "aspf: %i\n", s->aspf); -+ av_log(s->avctx, AV_LOG_DEBUG, "lfe: %i\n", s->lfe); -+ av_log(s->avctx, AV_LOG_DEBUG, "predictor history: %i\n", -+ s->predictor_history); -+ av_log(s->avctx, AV_LOG_DEBUG, "header crc: %i\n", s->header_crc); -+ av_log(s->avctx, AV_LOG_DEBUG, "multirate inter: %i\n", -+ s->multirate_inter); -+ av_log(s->avctx, AV_LOG_DEBUG, "version number: %i\n", s->version); -+ av_log(s->avctx, AV_LOG_DEBUG, "copy history: %i\n", s->copy_history); -+ av_log(s->avctx, AV_LOG_DEBUG, -+ "source pcm resolution: %i (%i bits/sample)\n", -+ s->source_pcm_res, dca_bits_per_sample[s->source_pcm_res]); -+ av_log(s->avctx, AV_LOG_DEBUG, "front sum: %i\n", s->front_sum); -+ av_log(s->avctx, AV_LOG_DEBUG, "surround sum: %i\n", s->surround_sum); -+ av_log(s->avctx, AV_LOG_DEBUG, "dialog norm: %i\n", s->dialog_norm); -+ av_log(s->avctx, AV_LOG_DEBUG, "\n"); -+#endif -+ -+ /* Primary audio coding header */ -+ s->subframes = get_bits(&s->gb, 4) + 1; -+ -+ return dca_parse_audio_coding_header(s, 0, 0); -+} -+ -+ -+static inline int get_scale(GetBitContext *gb, int level, int value, int log2range) -+{ -+ if (level < 5) { -+ /* huffman encoded */ -+ value += get_bitalloc(gb, &dca_scalefactor, level); -+ value = av_clip(value, 0, (1 << log2range) - 1); -+ } else if (level < 8) { -+ if (level + 1 > log2range) { -+ skip_bits(gb, level + 1 - log2range); -+ value = get_bits(gb, log2range); -+ } else { -+ value = get_bits(gb, level + 1); -+ } -+ } -+ return value; -+} -+ -+static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) -+{ -+ /* Primary audio coding side information */ -+ int j, k; -+ -+ if (get_bits_left(&s->gb) < 0) -+ return AVERROR_INVALIDDATA; -+ -+ if (!base_channel) { -+ s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1; -+ s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3); -+ } -+ -+ for (j = base_channel; j < s->prim_channels; j++) { -+ for (k = 0; k < s->subband_activity[j]; k++) -+ s->prediction_mode[j][k] = get_bits(&s->gb, 1); -+ } -+ -+ /* Get prediction codebook */ -+ for (j = base_channel; j < s->prim_channels; j++) { -+ for (k = 0; k < s->subband_activity[j]; k++) { -+ if (s->prediction_mode[j][k] > 0) { -+ /* (Prediction coefficient VQ address) */ -+ s->prediction_vq[j][k] = get_bits(&s->gb, 12); -+ } -+ } -+ } -+ -+ /* Bit allocation index */ -+ for (j = base_channel; j < s->prim_channels; j++) { -+ for (k = 0; k < s->vq_start_subband[j]; k++) { -+ if (s->bitalloc_huffman[j] == 6) -+ s->bitalloc[j][k] = get_bits(&s->gb, 5); -+ else if (s->bitalloc_huffman[j] == 5) -+ s->bitalloc[j][k] = get_bits(&s->gb, 4); -+ else if (s->bitalloc_huffman[j] == 7) { -+ av_log(s->avctx, AV_LOG_ERROR, -+ "Invalid bit allocation index\n"); -+ return AVERROR_INVALIDDATA; -+ } else { -+ s->bitalloc[j][k] = -+ get_bitalloc(&s->gb, &dca_bitalloc_index, s->bitalloc_huffman[j]); -+ } -+ -+ if (s->bitalloc[j][k] > 26) { -+ av_dlog(s->avctx, "bitalloc index [%i][%i] too big (%i)\n", -+ j, k, s->bitalloc[j][k]); -+ return AVERROR_INVALIDDATA; -+ } -+ } -+ } -+ -+ /* Transition mode */ -+ for (j = base_channel; j < s->prim_channels; j++) { -+ for (k = 0; k < s->subband_activity[j]; k++) { -+ s->transition_mode[j][k] = 0; -+ if (s->subsubframes[s->current_subframe] > 1 && -+ k < s->vq_start_subband[j] && s->bitalloc[j][k] > 0) { -+ s->transition_mode[j][k] = -+ get_bitalloc(&s->gb, &dca_tmode, s->transient_huffman[j]); -+ } -+ } -+ } -+ -+ if (get_bits_left(&s->gb) < 0) -+ return AVERROR_INVALIDDATA; -+ -+ for (j = base_channel; j < s->prim_channels; j++) { -+ const uint32_t *scale_table; -+ int scale_sum, log_size; -+ -+ memset(s->scale_factor[j], 0, -+ s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2); -+ -+ if (s->scalefactor_huffman[j] == 6) { -+ scale_table = scale_factor_quant7; -+ log_size = 7; -+ } else { -+ scale_table = scale_factor_quant6; -+ log_size = 6; -+ } -+ -+ /* When huffman coded, only the difference is encoded */ -+ scale_sum = 0; -+ -+ for (k = 0; k < s->subband_activity[j]; k++) { -+ if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) { -+ scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum, log_size); -+ s->scale_factor[j][k][0] = scale_table[scale_sum]; -+ } -+ -+ if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) { -+ /* Get second scale factor */ -+ scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum, log_size); -+ s->scale_factor[j][k][1] = scale_table[scale_sum]; -+ } -+ } -+ } -+ -+ /* Joint subband scale factor codebook select */ -+ for (j = base_channel; j < s->prim_channels; j++) { -+ /* Transmitted only if joint subband coding enabled */ -+ if (s->joint_intensity[j] > 0) -+ s->joint_huff[j] = get_bits(&s->gb, 3); -+ } -+ -+ if (get_bits_left(&s->gb) < 0) -+ return AVERROR_INVALIDDATA; -+ -+ /* Scale factors for joint subband coding */ -+ for (j = base_channel; j < s->prim_channels; j++) { -+ int source_channel; -+ -+ /* Transmitted only if joint subband coding enabled */ -+ if (s->joint_intensity[j] > 0) { -+ int scale = 0; -+ source_channel = s->joint_intensity[j] - 1; -+ -+ /* When huffman coded, only the difference is encoded -+ * (is this valid as well for joint scales ???) */ -+ -+ for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) { -+ scale = get_scale(&s->gb, s->joint_huff[j], 64 /* bias */, 7); -+ s->joint_scale_factor[j][k] = scale; /*joint_scale_table[scale]; */ -+ } -+ -+ if (!(s->debug_flag & 0x02)) { -+ av_log(s->avctx, AV_LOG_DEBUG, -+ "Joint stereo coding not supported\n"); -+ s->debug_flag |= 0x02; -+ } -+ } -+ } -+ -+ /* Stereo downmix coefficients */ -+ if (!base_channel && s->prim_channels > 2) { -+ if (s->downmix) { -+ for (j = base_channel; j < s->prim_channels; j++) { -+ s->downmix_coef[j][0] = get_bits(&s->gb, 7); -+ s->downmix_coef[j][1] = get_bits(&s->gb, 7); -+ } -+ } else { -+ int am = s->amode & DCA_CHANNEL_MASK; -+ if (am >= FF_ARRAY_ELEMS(dca_default_coeffs)) { -+ av_log(s->avctx, AV_LOG_ERROR, -+ "Invalid channel mode %d\n", am); -+ return AVERROR_INVALIDDATA; -+ } -+ for (j = base_channel; j < FFMIN(s->prim_channels, FF_ARRAY_ELEMS(dca_default_coeffs[am])); j++) { -+ s->downmix_coef[j][0] = dca_default_coeffs[am][j][0]; -+ s->downmix_coef[j][1] = dca_default_coeffs[am][j][1]; -+ } -+ } -+ } -+ -+ /* Dynamic range coefficient */ -+ if (!base_channel && s->dynrange) -+ s->dynrange_coef = get_bits(&s->gb, 8); -+ -+ /* Side information CRC check word */ -+ if (s->crc_present) { -+ get_bits(&s->gb, 16); -+ } -+ -+ /* -+ * Primary audio data arrays -+ */ -+ -+ /* VQ encoded high frequency subbands */ -+ for (j = base_channel; j < s->prim_channels; j++) -+ for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++) -+ /* 1 vector -> 32 samples */ -+ s->high_freq_vq[j][k] = get_bits(&s->gb, 10); -+ -+ /* Low frequency effect data */ -+ if (!base_channel && s->lfe) { -+ int quant7; -+ /* LFE samples */ -+ int lfe_samples = 2 * s->lfe * (4 + block_index); -+ int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]); -+ float lfe_scale; -+ -+ for (j = lfe_samples; j < lfe_end_sample; j++) { -+ /* Signed 8 bits int */ -+ s->lfe_data[j] = get_sbits(&s->gb, 8); -+ } -+ -+ /* Scale factor index */ -+ quant7 = get_bits(&s->gb, 8); -+ if (quant7 > 127) { -+ av_log_ask_for_sample(s->avctx, "LFEScaleIndex larger than 127\n"); -+ return AVERROR_INVALIDDATA; -+ } -+ s->lfe_scale_factor = scale_factor_quant7[quant7]; -+ -+ /* Quantization step size * scale factor */ -+ lfe_scale = 0.035 * s->lfe_scale_factor; -+ -+ for (j = lfe_samples; j < lfe_end_sample; j++) -+ s->lfe_data[j] *= lfe_scale; -+ } -+ -+#ifdef TRACE -+ av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", -+ s->subsubframes[s->current_subframe]); -+ av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n", -+ s->partial_samples[s->current_subframe]); -+ -+ for (j = base_channel; j < s->prim_channels; j++) { -+ av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:"); -+ for (k = 0; k < s->subband_activity[j]; k++) -+ av_log(s->avctx, AV_LOG_DEBUG, " %i", s->prediction_mode[j][k]); -+ av_log(s->avctx, AV_LOG_DEBUG, "\n"); -+ } -+ for (j = base_channel; j < s->prim_channels; j++) { -+ for (k = 0; k < s->subband_activity[j]; k++) -+ av_log(s->avctx, AV_LOG_DEBUG, -+ "prediction coefs: %f, %f, %f, %f\n", -+ (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192, -+ (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192, -+ (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192, -+ (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192); -+ } -+ for (j = base_channel; j < s->prim_channels; j++) { -+ av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: "); -+ for (k = 0; k < s->vq_start_subband[j]; k++) -+ av_log(s->avctx, AV_LOG_DEBUG, "%2.2i ", s->bitalloc[j][k]); -+ av_log(s->avctx, AV_LOG_DEBUG, "\n"); -+ } -+ for (j = base_channel; j < s->prim_channels; j++) { -+ av_log(s->avctx, AV_LOG_DEBUG, "Transition mode:"); -+ for (k = 0; k < s->subband_activity[j]; k++) -+ av_log(s->avctx, AV_LOG_DEBUG, " %i", s->transition_mode[j][k]); -+ av_log(s->avctx, AV_LOG_DEBUG, "\n"); -+ } -+ for (j = base_channel; j < s->prim_channels; j++) { -+ av_log(s->avctx, AV_LOG_DEBUG, "Scale factor:"); -+ for (k = 0; k < s->subband_activity[j]; k++) { -+ if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) -+ av_log(s->avctx, AV_LOG_DEBUG, " %i", s->scale_factor[j][k][0]); -+ if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) -+ av_log(s->avctx, AV_LOG_DEBUG, " %i(t)", s->scale_factor[j][k][1]); -+ } -+ av_log(s->avctx, AV_LOG_DEBUG, "\n"); -+ } -+ for (j = base_channel; j < s->prim_channels; j++) { -+ if (s->joint_intensity[j] > 0) { -+ int source_channel = s->joint_intensity[j] - 1; -+ av_log(s->avctx, AV_LOG_DEBUG, "Joint scale factor index:\n"); -+ for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) -+ av_log(s->avctx, AV_LOG_DEBUG, " %i", s->joint_scale_factor[j][k]); -+ av_log(s->avctx, AV_LOG_DEBUG, "\n"); -+ } -+ } -+ if (!base_channel && s->prim_channels > 2 && s->downmix) { -+ av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n"); -+ for (j = 0; j < s->prim_channels; j++) { -+ av_log(s->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", j, -+ dca_downmix_coeffs[s->downmix_coef[j][0]]); -+ av_log(s->avctx, AV_LOG_DEBUG, "Channel 1, %d = %f\n", j, -+ dca_downmix_coeffs[s->downmix_coef[j][1]]); -+ } -+ av_log(s->avctx, AV_LOG_DEBUG, "\n"); -+ } -+ for (j = base_channel; j < s->prim_channels; j++) -+ for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++) -+ av_log(s->avctx, AV_LOG_DEBUG, "VQ index: %i\n", s->high_freq_vq[j][k]); -+ if (!base_channel && s->lfe) { -+ int lfe_samples = 2 * s->lfe * (4 + block_index); -+ int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]); -+ -+ av_log(s->avctx, AV_LOG_DEBUG, "LFE samples:\n"); -+ for (j = lfe_samples; j < lfe_end_sample; j++) -+ av_log(s->avctx, AV_LOG_DEBUG, " %f", s->lfe_data[j]); -+ av_log(s->avctx, AV_LOG_DEBUG, "\n"); -+ } -+#endif -+ -+ return 0; -+} -+ -+static void qmf_32_subbands(DCAContext *s, int chans, -+ float samples_in[32][8], float *samples_out, -+ float scale) -+{ -+ const float *prCoeff; -+ int i; -+ -+ int sb_act = s->subband_activity[chans]; -+ int subindex; -+ -+ scale *= sqrt(1 / 8.0); -+ -+ /* Select filter */ -+ if (!s->multirate_inter) /* Non-perfect reconstruction */ -+ prCoeff = fir_32bands_nonperfect; -+ else /* Perfect reconstruction */ -+ prCoeff = fir_32bands_perfect; -+ -+ for (i = sb_act; i < 32; i++) -+ s->raXin[i] = 0.0; -+ -+ /* Reconstructed channel sample index */ -+ for (subindex = 0; subindex < 8; subindex++) { -+ /* Load in one sample from each subband and clear inactive subbands */ -+ for (i = 0; i < sb_act; i++) { -+ unsigned sign = (i - 1) & 2; -+ uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ sign << 30; -+ AV_WN32A(&s->raXin[i], v); -+ } -+ -+ s->synth.synth_filter_float(&s->imdct, -+ s->subband_fir_hist[chans], -+ &s->hist_index[chans], -+ s->subband_fir_noidea[chans], prCoeff, -+ samples_out, s->raXin, scale); -+ samples_out += 32; -+ } -+} -+ -+static void lfe_interpolation_fir(DCAContext *s, int decimation_select, -+ int num_deci_sample, float *samples_in, -+ float *samples_out, float scale) -+{ -+ /* samples_in: An array holding decimated samples. -+ * Samples in current subframe starts from samples_in[0], -+ * while samples_in[-1], samples_in[-2], ..., stores samples -+ * from last subframe as history. -+ * -+ * samples_out: An array holding interpolated samples -+ */ -+ -+ int decifactor; -+ const float *prCoeff; -+ int deciindex; -+ -+ /* Select decimation filter */ -+ if (decimation_select == 1) { -+ decifactor = 64; -+ prCoeff = lfe_fir_128; -+ } else { -+ decifactor = 32; -+ prCoeff = lfe_fir_64; -+ } -+ /* Interpolation */ -+ for (deciindex = 0; deciindex < num_deci_sample; deciindex++) { -+ s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor, scale); -+ samples_in++; -+ samples_out += 2 * decifactor; -+ } -+} -+ -+/* downmixing routines */ -+#define MIX_REAR1(samples, s1, rs, coef) \ -+ samples[0][i] += samples[s1][i] * coef[rs][0]; \ -+ samples[1][i] += samples[s1][i] * coef[rs][1]; -+ -+#define MIX_REAR2(samples, s1, s2, rs, coef) \ -+ samples[0][i] += samples[s1][i] * coef[rs][0] + samples[s2][i] * coef[rs + 1][0]; \ -+ samples[1][i] += samples[s1][i] * coef[rs][1] + samples[s2][i] * coef[rs + 1][1]; -+ -+#define MIX_FRONT3(samples, coef) \ -+ t = samples[c][i]; \ -+ u = samples[l][i]; \ -+ v = samples[r][i]; \ -+ samples[0][i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \ -+ samples[1][i] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1]; -+ -+#define DOWNMIX_TO_STEREO(op1, op2) \ -+ for (i = 0; i < 256; i++) { \ -+ op1 \ -+ op2 \ -+ } -+ -+static void dca_downmix(float **samples, int srcfmt, -+ int downmix_coef[DCA_PRIM_CHANNELS_MAX][2], -+ const int8_t *channel_mapping) -+{ -+ int c, l, r, sl, sr, s; -+ int i; -+ float t, u, v; -+ float coef[DCA_PRIM_CHANNELS_MAX][2]; -+ -+ for (i = 0; i < DCA_PRIM_CHANNELS_MAX; i++) { -+ coef[i][0] = dca_downmix_coeffs[downmix_coef[i][0]]; -+ coef[i][1] = dca_downmix_coeffs[downmix_coef[i][1]]; -+ } -+ -+ switch (srcfmt) { -+ case DCA_MONO: -+ case DCA_CHANNEL: -+ case DCA_STEREO_TOTAL: -+ case DCA_STEREO_SUMDIFF: -+ case DCA_4F2R: -+ av_log(NULL, AV_LOG_ERROR, "Not implemented!\n"); -+ break; -+ case DCA_STEREO: -+ break; -+ case DCA_3F: -+ c = channel_mapping[0]; -+ l = channel_mapping[1]; -+ r = channel_mapping[2]; -+ DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), ); -+ break; -+ case DCA_2F1R: -+ s = channel_mapping[2]; -+ DOWNMIX_TO_STEREO(MIX_REAR1(samples, s, 2, coef), ); -+ break; -+ case DCA_3F1R: -+ c = channel_mapping[0]; -+ l = channel_mapping[1]; -+ r = channel_mapping[2]; -+ s = channel_mapping[3]; -+ DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), -+ MIX_REAR1(samples, s, 3, coef)); -+ break; -+ case DCA_2F2R: -+ sl = channel_mapping[2]; -+ sr = channel_mapping[3]; -+ DOWNMIX_TO_STEREO(MIX_REAR2(samples, sl, sr, 2, coef), ); -+ break; -+ case DCA_3F2R: -+ c = channel_mapping[0]; -+ l = channel_mapping[1]; -+ r = channel_mapping[2]; -+ sl = channel_mapping[3]; -+ sr = channel_mapping[4]; -+ DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), -+ MIX_REAR2(samples, sl, sr, 3, coef)); -+ break; -+ } -+} -+ -+ -+#ifndef decode_blockcodes -+/* Very compact version of the block code decoder that does not use table -+ * look-up but is slightly slower */ -+static int decode_blockcode(int code, int levels, int *values) -+{ -+ int i; -+ int offset = (levels - 1) >> 1; -+ -+ for (i = 0; i < 4; i++) { -+ int div = FASTDIV(code, levels); -+ values[i] = code - offset - div * levels; -+ code = div; -+ } -+ -+ return code; -+} -+ -+static int decode_blockcodes(int code1, int code2, int levels, int *values) -+{ -+ return decode_blockcode(code1, levels, values) | -+ decode_blockcode(code2, levels, values + 4); -+} -+#endif -+ -+static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 }; -+static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 }; -+ -+#ifndef int8x8_fmul_int32 -+static inline void int8x8_fmul_int32(float *dst, const int8_t *src, int scale) -+{ -+ float fscale = scale / 16.0; -+ int i; -+ for (i = 0; i < 8; i++) -+ dst[i] = src[i] * fscale; -+} -+#endif -+ -+static int dca_subsubframe(DCAContext *s, int base_channel, int block_index) -+{ -+ int k, l; -+ int subsubframe = s->current_subsubframe; -+ -+ const float *quant_step_table; -+ -+ /* FIXME */ -+ float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index]; -+ LOCAL_ALIGNED_16(int, block, [8 * DCA_SUBBANDS]); -+ -+ /* -+ * Audio data -+ */ -+ -+ /* Select quantization step size table */ -+ if (s->bit_rate_index == 0x1f) -+ quant_step_table = lossless_quant_d; -+ else -+ quant_step_table = lossy_quant_d; -+ -+ for (k = base_channel; k < s->prim_channels; k++) { -+ float rscale[DCA_SUBBANDS]; -+ -+ if (get_bits_left(&s->gb) < 0) -+ return AVERROR_INVALIDDATA; -+ -+ for (l = 0; l < s->vq_start_subband[k]; l++) { -+ int m; -+ -+ /* Select the mid-tread linear quantizer */ -+ int abits = s->bitalloc[k][l]; -+ -+ float quant_step_size = quant_step_table[abits]; -+ -+ /* -+ * Determine quantization index code book and its type -+ */ -+ -+ /* Select quantization index code book */ -+ int sel = s->quant_index_huffman[k][abits]; -+ -+ /* -+ * Extract bits from the bit stream -+ */ -+ if (!abits) { -+ rscale[l] = 0; -+ memset(block + 8 * l, 0, 8 * sizeof(block[0])); -+ } else { -+ /* Deal with transients */ -+ int sfi = s->transition_mode[k][l] && subsubframe >= s->transition_mode[k][l]; -+ rscale[l] = quant_step_size * s->scale_factor[k][l][sfi] * -+ s->scalefactor_adj[k][sel]; -+ -+ if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table) { -+ if (abits <= 7) { -+ /* Block code */ -+ int block_code1, block_code2, size, levels, err; -+ -+ size = abits_sizes[abits - 1]; -+ levels = abits_levels[abits - 1]; -+ -+ block_code1 = get_bits(&s->gb, size); -+ block_code2 = get_bits(&s->gb, size); -+ err = decode_blockcodes(block_code1, block_code2, -+ levels, block + 8 * l); -+ if (err) { -+ av_log(s->avctx, AV_LOG_ERROR, -+ "ERROR: block code look-up failed\n"); -+ return AVERROR_INVALIDDATA; -+ } -+ } else { -+ /* no coding */ -+ for (m = 0; m < 8; m++) -+ block[8 * l + m] = get_sbits(&s->gb, abits - 3); -+ } -+ } else { -+ /* Huffman coded */ -+ for (m = 0; m < 8; m++) -+ block[8 * l + m] = get_bitalloc(&s->gb, -+ &dca_smpl_bitalloc[abits], sel); -+ } -+ -+ } -+ } -+ -+ s->fmt_conv.int32_to_float_fmul_scalar_array(&s->fmt_conv, subband_samples[k][0], -+ block, rscale, 8 * s->vq_start_subband[k]); -+ -+ for (l = 0; l < s->vq_start_subband[k]; l++) { -+ int m; -+ /* -+ * Inverse ADPCM if in prediction mode -+ */ -+ if (s->prediction_mode[k][l]) { -+ int n; -+ for (m = 0; m < 8; m++) { -+ for (n = 1; n <= 4; n++) -+ if (m >= n) -+ subband_samples[k][l][m] += -+ (adpcm_vb[s->prediction_vq[k][l]][n - 1] * -+ subband_samples[k][l][m - n] / 8192); -+ else if (s->predictor_history) -+ subband_samples[k][l][m] += -+ (adpcm_vb[s->prediction_vq[k][l]][n - 1] * -+ s->subband_samples_hist[k][l][m - n + 4] / 8192); -+ } -+ } -+ } -+ -+ /* -+ * Decode VQ encoded high frequencies -+ */ -+ for (l = s->vq_start_subband[k]; l < s->subband_activity[k]; l++) { -+ /* 1 vector -> 32 samples but we only need the 8 samples -+ * for this subsubframe. */ -+ int hfvq = s->high_freq_vq[k][l]; -+ -+ if (!s->debug_flag & 0x01) { -+ av_log(s->avctx, AV_LOG_DEBUG, -+ "Stream with high frequencies VQ coding\n"); -+ s->debug_flag |= 0x01; -+ } -+ -+ int8x8_fmul_int32(subband_samples[k][l], -+ &high_freq_vq[hfvq][subsubframe * 8], -+ s->scale_factor[k][l][0]); -+ } -+ } -+ -+ /* Check for DSYNC after subsubframe */ -+ if (s->aspf || subsubframe == s->subsubframes[s->current_subframe] - 1) { -+ if (0xFFFF == get_bits(&s->gb, 16)) { /* 0xFFFF */ -+#ifdef TRACE -+ av_log(s->avctx, AV_LOG_DEBUG, "Got subframe DSYNC\n"); -+#endif -+ } else { -+ av_log(s->avctx, AV_LOG_ERROR, "Didn't get subframe DSYNC\n"); -+ } -+ } -+ -+ /* Backup predictor history for adpcm */ -+ for (k = base_channel; k < s->prim_channels; k++) -+ for (l = 0; l < s->vq_start_subband[k]; l++) -+ memcpy(s->subband_samples_hist[k][l], -+ &subband_samples[k][l][4], -+ 4 * sizeof(subband_samples[0][0][0])); -+ -+ return 0; -+} -+ -+static int dca_filter_channels(DCAContext *s, int block_index) -+{ -+ float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index]; -+ int k; -+ -+ /* 32 subbands QMF */ -+ for (k = 0; k < s->prim_channels; k++) { -+/* static float pcm_to_double[8] = { 32768.0, 32768.0, 524288.0, 524288.0, -+ 0, 8388608.0, 8388608.0 };*/ -+ if (s->channel_order_tab[k] >= 0) -+ qmf_32_subbands(s, k, subband_samples[k], -+ s->samples_chanptr[s->channel_order_tab[k]], -+ M_SQRT1_2 / 32768.0 /* pcm_to_double[s->source_pcm_res] */); -+ } -+ -+ /* Down mixing */ -+ if (s->avctx->request_channels == 2 && s->prim_channels > 2) { -+ dca_downmix(s->samples_chanptr, s->amode, s->downmix_coef, s->channel_order_tab); -+ } -+ -+ /* Generate LFE samples for this subsubframe FIXME!!! */ -+ if (s->output & DCA_LFE) { -+ lfe_interpolation_fir(s, s->lfe, 2 * s->lfe, -+ s->lfe_data + 2 * s->lfe * (block_index + 4), -+ s->samples_chanptr[s->lfe_index], -+ 1.0 / (256.0 * 32768.0)); -+ /* Outputs 20bits pcm samples */ -+ } -+ -+ return 0; -+} -+ -+ -+static int dca_subframe_footer(DCAContext *s, int base_channel) -+{ -+ int aux_data_count = 0, i; -+ -+ /* -+ * Unpack optional information -+ */ -+ -+ /* presumably optional information only appears in the core? */ -+ if (!base_channel) { -+ if (s->timestamp) -+ skip_bits_long(&s->gb, 32); -+ -+ if (s->aux_data) -+ aux_data_count = get_bits(&s->gb, 6); -+ -+ for (i = 0; i < aux_data_count; i++) -+ get_bits(&s->gb, 8); -+ -+ if (s->crc_present && (s->downmix || s->dynrange)) -+ get_bits(&s->gb, 16); -+ } -+ -+ return 0; -+} -+ -+/** -+ * Decode a dca frame block -+ * -+ * @param s pointer to the DCAContext -+ */ -+ -+static int dca_decode_block(DCAContext *s, int base_channel, int block_index) -+{ -+ int ret; -+ -+ /* Sanity check */ -+ if (s->current_subframe >= s->subframes) { -+ av_log(s->avctx, AV_LOG_DEBUG, "check failed: %i>%i", -+ s->current_subframe, s->subframes); -+ return AVERROR_INVALIDDATA; -+ } -+ -+ if (!s->current_subsubframe) { -+#ifdef TRACE -+ av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_header\n"); -+#endif -+ /* Read subframe header */ -+ if ((ret = dca_subframe_header(s, base_channel, block_index))) -+ return ret; -+ } -+ -+ /* Read subsubframe */ -+#ifdef TRACE -+ av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subsubframe\n"); -+#endif -+ if ((ret = dca_subsubframe(s, base_channel, block_index))) -+ return ret; -+ -+ /* Update state */ -+ s->current_subsubframe++; -+ if (s->current_subsubframe >= s->subsubframes[s->current_subframe]) { -+ s->current_subsubframe = 0; -+ s->current_subframe++; -+ } -+ if (s->current_subframe >= s->subframes) { -+#ifdef TRACE -+ av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_footer\n"); -+#endif -+ /* Read subframe footer */ -+ if ((ret = dca_subframe_footer(s, base_channel))) -+ return ret; -+ } -+ -+ return 0; -+} -+ -+/** -+ * Return the number of channels in an ExSS speaker mask (HD) -+ */ -+static int dca_exss_mask2count(int mask) -+{ -+ /* count bits that mean speaker pairs twice */ -+ return av_popcount(mask) + -+ av_popcount(mask & (DCA_EXSS_CENTER_LEFT_RIGHT | -+ DCA_EXSS_FRONT_LEFT_RIGHT | -+ DCA_EXSS_FRONT_HIGH_LEFT_RIGHT | -+ DCA_EXSS_WIDE_LEFT_RIGHT | -+ DCA_EXSS_SIDE_LEFT_RIGHT | -+ DCA_EXSS_SIDE_HIGH_LEFT_RIGHT | -+ DCA_EXSS_SIDE_REAR_LEFT_RIGHT | -+ DCA_EXSS_REAR_LEFT_RIGHT | -+ DCA_EXSS_REAR_HIGH_LEFT_RIGHT)); -+} -+ -+/** -+ * Skip mixing coefficients of a single mix out configuration (HD) -+ */ -+static void dca_exss_skip_mix_coeffs(GetBitContext *gb, int channels, int out_ch) -+{ -+ int i; -+ -+ for (i = 0; i < channels; i++) { -+ int mix_map_mask = get_bits(gb, out_ch); -+ int num_coeffs = av_popcount(mix_map_mask); -+ skip_bits_long(gb, num_coeffs * 6); -+ } -+} -+ -+/** -+ * Parse extension substream asset header (HD) -+ */ -+static int dca_exss_parse_asset_header(DCAContext *s) -+{ -+ int header_pos = get_bits_count(&s->gb); -+ int header_size; -+ int channels = 0; -+ int embedded_stereo = 0; -+ int embedded_6ch = 0; -+ int drc_code_present; -+ int av_uninit(extensions_mask); -+ int i, j; -+ -+ if (get_bits_left(&s->gb) < 16) -+ return -1; -+ -+ /* We will parse just enough to get to the extensions bitmask with which -+ * we can set the profile value. */ -+ -+ header_size = get_bits(&s->gb, 9) + 1; -+ skip_bits(&s->gb, 3); // asset index -+ -+ if (s->static_fields) { -+ if (get_bits1(&s->gb)) -+ skip_bits(&s->gb, 4); // asset type descriptor -+ if (get_bits1(&s->gb)) -+ skip_bits_long(&s->gb, 24); // language descriptor -+ -+ if (get_bits1(&s->gb)) { -+ /* How can one fit 1024 bytes of text here if the maximum value -+ * for the asset header size field above was 512 bytes? */ -+ int text_length = get_bits(&s->gb, 10) + 1; -+ if (get_bits_left(&s->gb) < text_length * 8) -+ return -1; -+ skip_bits_long(&s->gb, text_length * 8); // info text -+ } -+ -+ skip_bits(&s->gb, 5); // bit resolution - 1 -+ skip_bits(&s->gb, 4); // max sample rate code -+ channels = get_bits(&s->gb, 8) + 1; -+ -+ if (get_bits1(&s->gb)) { // 1-to-1 channels to speakers -+ int spkr_remap_sets; -+ int spkr_mask_size = 16; -+ int num_spkrs[7]; -+ -+ if (channels > 2) -+ embedded_stereo = get_bits1(&s->gb); -+ if (channels > 6) -+ embedded_6ch = get_bits1(&s->gb); -+ -+ if (get_bits1(&s->gb)) { -+ spkr_mask_size = (get_bits(&s->gb, 2) + 1) << 2; -+ skip_bits(&s->gb, spkr_mask_size); // spkr activity mask -+ } -+ -+ spkr_remap_sets = get_bits(&s->gb, 3); -+ -+ for (i = 0; i < spkr_remap_sets; i++) { -+ /* std layout mask for each remap set */ -+ num_spkrs[i] = dca_exss_mask2count(get_bits(&s->gb, spkr_mask_size)); -+ } -+ -+ for (i = 0; i < spkr_remap_sets; i++) { -+ int num_dec_ch_remaps = get_bits(&s->gb, 5) + 1; -+ if (get_bits_left(&s->gb) < 0) -+ return -1; -+ -+ for (j = 0; j < num_spkrs[i]; j++) { -+ int remap_dec_ch_mask = get_bits_long(&s->gb, num_dec_ch_remaps); -+ int num_dec_ch = av_popcount(remap_dec_ch_mask); -+ skip_bits_long(&s->gb, num_dec_ch * 5); // remap codes -+ } -+ } -+ -+ } else { -+ skip_bits(&s->gb, 3); // representation type -+ } -+ } -+ -+ drc_code_present = get_bits1(&s->gb); -+ if (drc_code_present) -+ get_bits(&s->gb, 8); // drc code -+ -+ if (get_bits1(&s->gb)) -+ skip_bits(&s->gb, 5); // dialog normalization code -+ -+ if (drc_code_present && embedded_stereo) -+ get_bits(&s->gb, 8); // drc stereo code -+ -+ if (s->mix_metadata && get_bits1(&s->gb)) { -+ skip_bits(&s->gb, 1); // external mix -+ skip_bits(&s->gb, 6); // post mix gain code -+ -+ if (get_bits(&s->gb, 2) != 3) // mixer drc code -+ skip_bits(&s->gb, 3); // drc limit -+ else -+ skip_bits(&s->gb, 8); // custom drc code -+ -+ if (get_bits1(&s->gb)) // channel specific scaling -+ for (i = 0; i < s->num_mix_configs; i++) -+ skip_bits_long(&s->gb, s->mix_config_num_ch[i] * 6); // scale codes -+ else -+ skip_bits_long(&s->gb, s->num_mix_configs * 6); // scale codes -+ -+ for (i = 0; i < s->num_mix_configs; i++) { -+ if (get_bits_left(&s->gb) < 0) -+ return -1; -+ dca_exss_skip_mix_coeffs(&s->gb, channels, s->mix_config_num_ch[i]); -+ if (embedded_6ch) -+ dca_exss_skip_mix_coeffs(&s->gb, 6, s->mix_config_num_ch[i]); -+ if (embedded_stereo) -+ dca_exss_skip_mix_coeffs(&s->gb, 2, s->mix_config_num_ch[i]); -+ } -+ } -+ -+ switch (get_bits(&s->gb, 2)) { -+ case 0: extensions_mask = get_bits(&s->gb, 12); break; -+ case 1: extensions_mask = DCA_EXT_EXSS_XLL; break; -+ case 2: extensions_mask = DCA_EXT_EXSS_LBR; break; -+ case 3: extensions_mask = 0; /* aux coding */ break; -+ } -+ -+ /* not parsed further, we were only interested in the extensions mask */ -+ -+ if (get_bits_left(&s->gb) < 0) -+ return -1; -+ -+ if (get_bits_count(&s->gb) - header_pos > header_size * 8) { -+ av_log(s->avctx, AV_LOG_WARNING, "Asset header size mismatch.\n"); -+ return -1; -+ } -+ skip_bits_long(&s->gb, header_pos + header_size * 8 - get_bits_count(&s->gb)); -+ -+ if (extensions_mask & DCA_EXT_EXSS_XLL) -+ s->profile = FF_PROFILE_DTS_HD_MA; -+ else if (extensions_mask & (DCA_EXT_EXSS_XBR | DCA_EXT_EXSS_X96 | -+ DCA_EXT_EXSS_XXCH)) -+ s->profile = FF_PROFILE_DTS_HD_HRA; -+ -+ if (!(extensions_mask & DCA_EXT_CORE)) -+ av_log(s->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n"); -+ if ((extensions_mask & DCA_CORE_EXTS) != s->core_ext_mask) -+ av_log(s->avctx, AV_LOG_WARNING, -+ "DTS extensions detection mismatch (%d, %d)\n", -+ extensions_mask & DCA_CORE_EXTS, s->core_ext_mask); -+ -+ return 0; -+} -+ -+static int dca_xbr_parse_frame(DCAContext *s) -+{ -+ int scale_table_high[DCA_CHSET_CHANS_MAX][DCA_SUBBANDS][2]; -+ int active_bands[DCA_CHSETS_MAX][DCA_CHSET_CHANS_MAX]; -+ int abits_high[DCA_CHSET_CHANS_MAX][DCA_SUBBANDS]; -+ int anctemp[DCA_CHSET_CHANS_MAX]; -+ int chset_fsize[DCA_CHSETS_MAX]; -+ int n_xbr_ch[DCA_CHSETS_MAX]; -+ int hdr_size, num_chsets, xbr_tmode, hdr_pos; -+ int i, j, k, l, chset, chan_base; -+ -+ av_log(s->avctx, AV_LOG_DEBUG, "DTS-XBR: decoding XBR extension\n"); -+ -+ /* get bit position of sync header */ -+ hdr_pos = get_bits_count(&s->gb) - 32; -+ -+ hdr_size = get_bits(&s->gb, 6) + 1; -+ num_chsets = get_bits(&s->gb, 2) + 1; -+ -+ for(i = 0; i < num_chsets; i++) -+ chset_fsize[i] = get_bits(&s->gb, 14) + 1; -+ -+ xbr_tmode = get_bits1(&s->gb); -+ -+ for(i = 0; i < num_chsets; i++) { -+ n_xbr_ch[i] = get_bits(&s->gb, 3) + 1; -+ k = get_bits(&s->gb, 2) + 5; -+ for(j = 0; j < n_xbr_ch[i]; j++) -+ active_bands[i][j] = get_bits(&s->gb, k) + 1; -+ } -+ -+ /* skip to the end of the header */ -+ i = get_bits_count(&s->gb); -+ if(hdr_pos + hdr_size * 8 > i) -+ skip_bits_long(&s->gb, hdr_pos + hdr_size * 8 - i); -+ -+ /* loop over the channel data sets */ -+ /* only decode as many channels as we've decoded base data for */ -+ for(chset = 0, chan_base = 0; -+ chset < num_chsets && chan_base + n_xbr_ch[chset] <= s->prim_channels; -+ chan_base += n_xbr_ch[chset++]) { -+ int start_posn = get_bits_count(&s->gb); -+ int subsubframe = 0; -+ int subframe = 0; -+ -+ /* loop over subframes */ -+ for (k = 0; k < (s->sample_blocks / 8); k++) { -+ /* parse header if we're on first subsubframe of a block */ -+ if(subsubframe == 0) { -+ /* Parse subframe header */ -+ for(i = 0; i < n_xbr_ch[chset]; i++) { -+ anctemp[i] = get_bits(&s->gb, 2) + 2; -+ } -+ -+ for(i = 0; i < n_xbr_ch[chset]; i++) { -+ get_array(&s->gb, abits_high[i], active_bands[chset][i], anctemp[i]); -+ } -+ -+ for(i = 0; i < n_xbr_ch[chset]; i++) { -+ anctemp[i] = get_bits(&s->gb, 3); -+ if(anctemp[i] < 1) { -+ av_log(s->avctx, AV_LOG_ERROR, "DTS-XBR: SYNC ERROR\n"); -+ return AVERROR_INVALIDDATA; -+ } -+ } -+ -+ /* generate scale factors */ -+ for(i = 0; i < n_xbr_ch[chset]; i++) { -+ const uint32_t *scale_table; -+ int nbits; -+ -+ if (s->scalefactor_huffman[chan_base+i] == 6) { -+ scale_table = scale_factor_quant7; -+ } else { -+ scale_table = scale_factor_quant6; -+ } -+ -+ nbits = anctemp[i]; -+ -+ for(j = 0; j < active_bands[chset][i]; j++) { -+ if(abits_high[i][j] > 0) { -+ scale_table_high[i][j][0] = -+ scale_table[get_bits(&s->gb, nbits)]; -+ -+ if(xbr_tmode && s->transition_mode[i][j]) { -+ scale_table_high[i][j][1] = -+ scale_table[get_bits(&s->gb, nbits)]; -+ } -+ } -+ } -+ } -+ } -+ -+ /* decode audio array for this block */ -+ for(i = 0; i < n_xbr_ch[chset]; i++) { -+ for(j = 0; j < active_bands[chset][i]; j++) { -+ const int xbr_abits = abits_high[i][j]; -+ const float quant_step_size = lossless_quant_d[xbr_abits]; -+ const int sfi = xbr_tmode && s->transition_mode[i][j] && subsubframe >= s->transition_mode[i][j]; -+ const float rscale = quant_step_size * scale_table_high[i][j][sfi]; -+ float *subband_samples = s->subband_samples[k][chan_base+i][j]; -+ int block[8]; -+ -+ if(xbr_abits <= 0) -+ continue; -+ -+ if(xbr_abits > 7) { -+ get_array(&s->gb, block, 8, xbr_abits - 3); -+ } else { -+ int block_code1, block_code2, size, levels, err; -+ -+ size = abits_sizes[xbr_abits - 1]; -+ levels = abits_levels[xbr_abits - 1]; -+ -+ block_code1 = get_bits(&s->gb, size); -+ block_code2 = get_bits(&s->gb, size); -+ err = decode_blockcodes(block_code1, block_code2, -+ levels, block); -+ if (err) { -+ av_log(s->avctx, AV_LOG_ERROR, -+ "ERROR: DTS-XBR: block code look-up failed\n"); -+ return AVERROR_INVALIDDATA; -+ } -+ } -+ -+ /* scale & sum into subband */ -+ for(l = 0; l < 8; l++) -+ subband_samples[l] += (float)block[l] * rscale; -+ } -+ } -+ -+ /* check DSYNC marker */ -+ if(s->aspf || subsubframe == s->subsubframes[subframe] - 1) { -+ if(get_bits(&s->gb, 16) != 0xffff) { -+ av_log(s->avctx, AV_LOG_ERROR, "DTS-XBR: Didn't get subframe DSYNC\n"); -+ return AVERROR_INVALIDDATA; -+ } -+ } -+ -+ /* advance sub-sub-frame index */ -+ if(++subsubframe >= s->subsubframes[subframe]) { -+ subsubframe = 0; -+ subframe++; -+ } -+ } -+ -+ /* skip to next channel set */ -+ i = get_bits_count(&s->gb); -+ if(start_posn + chset_fsize[chset] * 8 != i) { -+ j = start_posn + chset_fsize[chset] * 8 - i; -+ if(j < 0 || j >= 8) -+ av_log(s->avctx, AV_LOG_ERROR, "DTS-XBR: end of channel set," -+ " skipping further than expected (%d bits)\n", j); -+ skip_bits_long(&s->gb, j); -+ } -+ } -+ -+ return 0; -+} -+ -+/* parse initial header for XXCH and dump details */ -+static int dca_xxch_decode_frame(DCAContext *s) -+{ -+ int hdr_size, spkmsk_bits, num_chsets, core_spk, hdr_pos; -+ int i, chset, base_channel, chstart, fsize[8]; -+ -+ /* assume header word has already been parsed */ -+ hdr_pos = get_bits_count(&s->gb) - 32; -+ hdr_size = get_bits(&s->gb, 6) + 1; -+ /*chhdr_crc =*/ skip_bits1(&s->gb); -+ spkmsk_bits = get_bits(&s->gb, 5) + 1; -+ num_chsets = get_bits(&s->gb, 2) + 1; -+ -+ for (i = 0; i < num_chsets; i++) -+ fsize[i] = get_bits(&s->gb, 14) + 1; -+ -+ core_spk = get_bits(&s->gb, spkmsk_bits); -+ s->xxch_core_spkmask = core_spk; -+ s->xxch_nbits_spk_mask = spkmsk_bits; -+ s->xxch_dmix_embedded = 0; -+ -+ /* skip to the end of the header */ -+ i = get_bits_count(&s->gb); -+ if (hdr_pos + hdr_size * 8 > i) -+ skip_bits_long(&s->gb, hdr_pos + hdr_size * 8 - i); -+ -+ for (chset = 0; chset < num_chsets; chset++) { -+ chstart = get_bits_count(&s->gb); -+ base_channel = s->prim_channels; -+ s->xxch_chset = chset; -+ -+ /* XXCH and Core headers differ, see 6.4.2 "XXCH Channel Set Header" vs. -+ 5.3.2 "Primary Audio Coding Header", DTS Spec 1.3.1 */ -+ dca_parse_audio_coding_header(s, base_channel, 1); -+ -+ /* decode channel data */ -+ for (i = 0; i < (s->sample_blocks / 8); i++) { -+ if (dca_decode_block(s, base_channel, i)) { -+ av_log(s->avctx, AV_LOG_ERROR, -+ "Error decoding DTS-XXCH extension\n"); -+ continue; -+ } -+ } -+ -+ /* skip to end of this section */ -+ i = get_bits_count(&s->gb); -+ if (chstart + fsize[chset] * 8 > i) -+ skip_bits_long(&s->gb, chstart + fsize[chset] * 8 - i); -+ } -+ s->xxch_chset = num_chsets; -+ -+ return 0; -+} -+ -+/** -+ * Parse extension substream header (HD) -+ */ -+static void dca_exss_parse_header(DCAContext *s) -+{ -+ int asset_size[8]; -+ int ss_index; -+ int blownup; -+ int num_audiop = 1; -+ int num_assets = 1; -+ int active_ss_mask[8]; -+ int i, j; -+ int start_posn; -+ int hdrsize; -+ uint32_t mkr; -+ -+ if (get_bits_left(&s->gb) < 52) -+ return; -+ -+ start_posn = get_bits_count(&s->gb) - 32; -+ -+ skip_bits(&s->gb, 8); // user data -+ ss_index = get_bits(&s->gb, 2); -+ -+ blownup = get_bits1(&s->gb); -+ hdrsize = get_bits(&s->gb, 8 + 4 * blownup) + 1; // header_size -+ skip_bits(&s->gb, 16 + 4 * blownup); // hd_size -+ -+ s->static_fields = get_bits1(&s->gb); -+ if (s->static_fields) { -+ skip_bits(&s->gb, 2); // reference clock code -+ skip_bits(&s->gb, 3); // frame duration code -+ -+ if (get_bits1(&s->gb)) -+ skip_bits_long(&s->gb, 36); // timestamp -+ -+ /* a single stream can contain multiple audio assets that can be -+ * combined to form multiple audio presentations */ -+ -+ num_audiop = get_bits(&s->gb, 3) + 1; -+ if (num_audiop > 1) { -+ av_log_ask_for_sample(s->avctx, "Multiple DTS-HD audio presentations."); -+ /* ignore such streams for now */ -+ return; -+ } -+ -+ num_assets = get_bits(&s->gb, 3) + 1; -+ if (num_assets > 1) { -+ av_log_ask_for_sample(s->avctx, "Multiple DTS-HD audio assets."); -+ /* ignore such streams for now */ -+ return; -+ } -+ -+ for (i = 0; i < num_audiop; i++) -+ active_ss_mask[i] = get_bits(&s->gb, ss_index + 1); -+ -+ for (i = 0; i < num_audiop; i++) -+ for (j = 0; j <= ss_index; j++) -+ if (active_ss_mask[i] & (1 << j)) -+ skip_bits(&s->gb, 8); // active asset mask -+ -+ s->mix_metadata = get_bits1(&s->gb); -+ if (s->mix_metadata) { -+ int mix_out_mask_size; -+ -+ skip_bits(&s->gb, 2); // adjustment level -+ mix_out_mask_size = (get_bits(&s->gb, 2) + 1) << 2; -+ s->num_mix_configs = get_bits(&s->gb, 2) + 1; -+ -+ for (i = 0; i < s->num_mix_configs; i++) { -+ int mix_out_mask = get_bits(&s->gb, mix_out_mask_size); -+ s->mix_config_num_ch[i] = dca_exss_mask2count(mix_out_mask); -+ } -+ } -+ } -+ -+ for (i = 0; i < num_assets; i++) -+ asset_size[i] = get_bits_long(&s->gb, 16 + 4 * blownup); -+ -+ for (i = 0; i < num_assets; i++) { -+ if (dca_exss_parse_asset_header(s)) -+ return; -+ } -+ -+ /* not parsed further, we were only interested in the extensions mask -+ * from the asset header */ -+ -+ if (num_assets > 0) { -+ j = get_bits_count(&s->gb); -+ if (start_posn + hdrsize * 8 > j) -+ skip_bits_long(&s->gb, start_posn + hdrsize * 8 - j); -+ -+ for (i = 0; i < num_assets; i++) { -+ start_posn = get_bits_count(&s->gb); -+ mkr = get_bits_long(&s->gb, 32); -+ -+ /* parse extensions that we know about */ -+ if (mkr == 0x655e315e) { -+ dca_xbr_parse_frame(s); -+ } else if (mkr == 0x47004a03) { -+ dca_xxch_decode_frame(s); -+ s->core_ext_mask |= DCA_EXT_XXCH; /* xxx use for chan reordering */ -+ } else { -+ av_log(s->avctx, AV_LOG_DEBUG, -+ "DTS-ExSS: unknown marker = 0x%08x\n", mkr); -+ } -+ -+ /* skip to end of block */ -+ j = get_bits_count(&s->gb); -+ if (start_posn + asset_size[i] * 8 > j) -+ skip_bits_long(&s->gb, start_posn + asset_size[i] * 8 - j); -+ } -+ } -+} -+ -+/** -+ * Main frame decoding function -+ * FIXME add arguments -+ */ -+static int dca_decode_frame(AVCodecContext *avctx, void *data, -+ int *got_frame_ptr, AVPacket *avpkt) -+{ -+ AVFrame *frame = data; -+ const uint8_t *buf = avpkt->data; -+ int buf_size = avpkt->size; -+ int channel_mask; -+ int channel_layout; -+ int lfe_samples; -+ int num_core_channels = 0; -+ int i, ret; -+ float **samples_flt; -+ float *src_chan; -+ float *dst_chan; -+ DCAContext *s = avctx->priv_data; -+ int core_ss_end; -+ int channels, full_channels; -+ float scale; -+ int achan; -+ int chset; -+ int mask; -+ int lavc; -+ int posn; -+ int j, k; -+ int endch; -+ -+ s->xch_present = 0; -+ -+ s->dca_buffer_size = ff_dca_convert_bitstream(buf, buf_size, s->dca_buffer, -+ DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE); -+ if (s->dca_buffer_size == AVERROR_INVALIDDATA) { -+ av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n"); -+ return AVERROR_INVALIDDATA; -+ } -+ -+ init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8); -+ if ((ret = dca_parse_frame_header(s)) < 0) { -+ //seems like the frame is corrupt, try with the next one -+ return ret; -+ } -+ //set AVCodec values with parsed data -+ avctx->sample_rate = s->sample_rate; -+ avctx->bit_rate = s->bit_rate; -+ -+ s->profile = FF_PROFILE_DTS; -+ -+ for (i = 0; i < (s->sample_blocks / 8); i++) { -+ if ((ret = dca_decode_block(s, 0, i))) { -+ av_log(avctx, AV_LOG_ERROR, "error decoding block\n"); -+ return ret; -+ } -+ } -+ -+ /* record number of core channels incase less than max channels are requested */ -+ num_core_channels = s->prim_channels; -+ -+ if (s->ext_coding) -+ s->core_ext_mask = dca_ext_audio_descr_mask[s->ext_descr]; -+ else -+ s->core_ext_mask = 0; -+ -+ core_ss_end = FFMIN(s->frame_size, s->dca_buffer_size) * 8; -+ -+ /* only scan for extensions if ext_descr was unknown or indicated a -+ * supported XCh extension */ -+ if (s->core_ext_mask < 0 || s->core_ext_mask & (DCA_EXT_XCH | DCA_EXT_XXCH)) { -+ -+ /* if ext_descr was unknown, clear s->core_ext_mask so that the -+ * extensions scan can fill it up */ -+ s->core_ext_mask = FFMAX(s->core_ext_mask, 0); -+ -+ /* extensions start at 32-bit boundaries into bitstream */ -+ skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31); -+ -+ while (core_ss_end - get_bits_count(&s->gb) >= 32) { -+ uint32_t bits = get_bits_long(&s->gb, 32); -+ -+ switch (bits) { -+ case 0x5a5a5a5a: { -+ int ext_amode, xch_fsize; -+ -+ s->xch_base_channel = s->prim_channels; -+ -+ /* validate sync word using XCHFSIZE field */ -+ xch_fsize = show_bits(&s->gb, 10); -+ if ((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) && -+ (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1)) -+ continue; -+ -+ /* skip length-to-end-of-frame field for the moment */ -+ skip_bits(&s->gb, 10); -+ -+ s->core_ext_mask |= DCA_EXT_XCH; -+ -+ /* extension amode(number of channels in extension) should be 1 */ -+ /* AFAIK XCh is not used for more channels */ -+ if ((ext_amode = get_bits(&s->gb, 4)) != 1) { -+ av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not" -+ " supported!\n", ext_amode); -+ continue; -+ } -+ -+ if (s->xch_base_channel < 2) { -+ av_log_ask_for_sample(avctx, "XCh with fewer than 2 base channels is not supported\n"); -+ continue; -+ } -+ -+ /* much like core primary audio coding header */ -+ dca_parse_audio_coding_header(s, s->xch_base_channel, 0); -+ -+ for (i = 0; i < (s->sample_blocks / 8); i++) -+ if ((ret = dca_decode_block(s, s->xch_base_channel, i))) { -+ av_log(avctx, AV_LOG_ERROR, "error decoding XCh extension\n"); -+ continue; -+ } -+ -+ s->xch_present = 1; -+ break; -+ } -+ case 0x47004a03: -+ /* XXCh: extended channels */ -+ /* usually found either in core or HD part in DTS-HD HRA streams, -+ * but not in DTS-ES which contains XCh extensions instead */ -+ s->core_ext_mask |= DCA_EXT_XXCH; -+ dca_xxch_decode_frame(s); -+ break; -+ -+ case 0x1d95f262: { -+ int fsize96 = show_bits(&s->gb, 12) + 1; -+ if (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + fsize96) -+ continue; -+ -+ av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\n", -+ get_bits_count(&s->gb)); -+ skip_bits(&s->gb, 12); -+ av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", fsize96); -+ av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4)); -+ -+ s->core_ext_mask |= DCA_EXT_X96; -+ break; -+ } -+ } -+ -+ skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31); -+ } -+ } else { -+ /* no supported extensions, skip the rest of the core substream */ -+ skip_bits_long(&s->gb, core_ss_end - get_bits_count(&s->gb)); -+ } -+ -+ if (s->core_ext_mask & DCA_EXT_X96) -+ s->profile = FF_PROFILE_DTS_96_24; -+ else if (s->core_ext_mask & (DCA_EXT_XCH | DCA_EXT_XXCH)) -+ s->profile = FF_PROFILE_DTS_ES; -+ -+ /* check for ExSS (HD part) */ -+ if (s->dca_buffer_size - s->frame_size > 32 && -+ get_bits_long(&s->gb, 32) == DCA_HD_MARKER) -+ dca_exss_parse_header(s); -+ -+ avctx->profile = s->profile; -+ -+ full_channels = channels = s->prim_channels + !!s->lfe; -+ -+ /* If we have XXCH then the channel layout is managed differently */ -+ /* note that XLL will also have another way to do things */ -+ if (!(s->core_ext_mask & DCA_EXT_XXCH) -+ || (s->core_ext_mask & DCA_EXT_XXCH && avctx->request_channels > 0 -+ && avctx->request_channels -+ < num_core_channels + !!s->lfe + s->xxch_chset_nch[0])) -+ { /* xxx should also do MA extensions */ -+ if (s->amode < 16) { -+ avctx->channel_layout = dca_core_channel_layout[s->amode]; -+ -+ if (s->xch_present && (!avctx->request_channels || -+ avctx->request_channels -+ > num_core_channels + !!s->lfe)) { -+ avctx->channel_layout |= AV_CH_BACK_CENTER; -+ if (s->lfe) { -+ avctx->channel_layout |= AV_CH_LOW_FREQUENCY; -+ s->channel_order_tab = dca_channel_reorder_lfe_xch[s->amode]; -+ } else { -+ s->channel_order_tab = dca_channel_reorder_nolfe_xch[s->amode]; -+ } -+ if (s->channel_order_tab[s->xch_base_channel] < 0) -+ return AVERROR_INVALIDDATA; -+ } else { -+ channels = num_core_channels + !!s->lfe; -+ s->xch_present = 0; /* disable further xch processing */ -+ if (s->lfe) { -+ avctx->channel_layout |= AV_CH_LOW_FREQUENCY; -+ s->channel_order_tab = dca_channel_reorder_lfe[s->amode]; -+ } else -+ s->channel_order_tab = dca_channel_reorder_nolfe[s->amode]; -+ } -+ -+ if (channels > !!s->lfe && -+ s->channel_order_tab[channels - 1 - !!s->lfe] < 0) -+ return AVERROR_INVALIDDATA; -+ -+ if (av_get_channel_layout_nb_channels(avctx->channel_layout) != channels) { -+ av_log(avctx, AV_LOG_ERROR, "Number of channels %d mismatches layout %d\n", channels, av_get_channel_layout_nb_channels(avctx->channel_layout)); -+ return AVERROR_INVALIDDATA; -+ } -+ -+ if (avctx->request_channels == 2 && s->prim_channels > 2) { -+ channels = 2; -+ s->output = DCA_STEREO; -+ avctx->channel_layout = AV_CH_LAYOUT_STEREO; -+ } -+ else if (avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE) { -+ static const int8_t dca_channel_order_native[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; -+ s->channel_order_tab = dca_channel_order_native; -+ } -+ s->lfe_index = dca_lfe_index[s->amode]; -+ } else { -+ av_log(avctx, AV_LOG_ERROR, -+ "Non standard configuration %d !\n", s->amode); -+ return AVERROR_INVALIDDATA; -+ } -+ -+ s->xxch_dmix_embedded = 0; -+ } else { -+ /* we only get here if an XXCH channel set can be added to the mix */ -+ channel_mask = s->xxch_core_spkmask; -+ -+ if (avctx->request_channels > 0 -+ && avctx->request_channels < s->prim_channels) { -+ channels = num_core_channels + !!s->lfe; -+ for (i = 0; i < s->xxch_chset && channels + s->xxch_chset_nch[i] -+ <= avctx->request_channels; i++) { -+ channels += s->xxch_chset_nch[i]; -+ channel_mask |= s->xxch_spk_masks[i]; -+ } -+ } else { -+ channels = s->prim_channels + !!s->lfe; -+ for (i = 0; i < s->xxch_chset; i++) { -+ channel_mask |= s->xxch_spk_masks[i]; -+ } -+ } -+ -+ /* Given the DTS spec'ed channel mask, generate an avcodec version */ -+ channel_layout = 0; -+ for (i = 0; i < s->xxch_nbits_spk_mask; ++i) { -+ if (channel_mask & (1 << i)) { -+ channel_layout |= map_xxch_to_native[i]; -+ } -+ } -+ -+ /* make sure that we have managed to get equivelant dts/avcodec channel -+ * masks in some sense -- unfortunately some channels could overlap */ -+ if (av_popcount(channel_mask) != av_popcount(channel_layout)) { -+ av_log(avctx, AV_LOG_DEBUG, -+ "DTS-XXCH: Inconsistant avcodec/dts channel layouts\n"); -+ return AVERROR_INVALIDDATA; -+ } -+ -+ avctx->channel_layout = channel_layout; -+ -+ if (!(avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE)) { -+ /* Estimate DTS --> avcodec ordering table */ -+ for (chset = -1, j = 0; chset < s->xxch_chset; ++chset) { -+ mask = chset >= 0 ? s->xxch_spk_masks[chset] -+ : s->xxch_core_spkmask; -+ for (i = 0; i < s->xxch_nbits_spk_mask; i++) { -+ if (mask & ~(DCA_XXCH_LFE1 | DCA_XXCH_LFE2) & (1 << i)) { -+ lavc = map_xxch_to_native[i]; -+ posn = av_popcount(channel_layout & (lavc - 1)); -+ s->xxch_order_tab[j++] = posn; -+ } -+ } -+ } -+ -+ s->lfe_index = av_popcount(channel_layout & (AV_CH_LOW_FREQUENCY-1)); -+ } else { /* native ordering */ -+ for (i = 0; i < channels; i++) -+ s->xxch_order_tab[i] = i; -+ -+ s->lfe_index = channels - 1; -+ } -+ -+ s->channel_order_tab = s->xxch_order_tab; -+ } -+ -+ if (avctx->channels != channels) { -+ if (avctx->channels) -+ av_log(avctx, AV_LOG_INFO, "Number of channels changed in DCA decoder (%d -> %d)\n", avctx->channels, channels); -+ avctx->channels = channels; -+ } -+ -+ /* get output buffer */ -+ frame->nb_samples = 256 * (s->sample_blocks / 8); -+ if ((ret = ff_get_buffer(avctx, frame)) < 0) { -+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); -+ return ret; -+ } -+ samples_flt = (float **)frame->extended_data; -+ -+ /* allocate buffer for extra channels if downmixing */ -+ if (avctx->channels < full_channels) { -+ ret = av_samples_get_buffer_size(NULL, full_channels - channels, -+ frame->nb_samples, -+ avctx->sample_fmt, 0); -+ if (ret < 0) -+ return ret; -+ -+ av_fast_malloc(&s->extra_channels_buffer, -+ &s->extra_channels_buffer_size, ret); -+ if (!s->extra_channels_buffer) -+ return AVERROR(ENOMEM); -+ -+ ret = av_samples_fill_arrays((uint8_t **)s->extra_channels, NULL, -+ s->extra_channels_buffer, -+ full_channels - channels, -+ frame->nb_samples, avctx->sample_fmt, 0); -+ if (ret < 0) -+ return ret; -+ } -+ -+ /* filter to get final output */ -+ for (i = 0; i < (s->sample_blocks / 8); i++) { -+ int ch; -+ -+ for (ch = 0; ch < channels; ch++) -+ s->samples_chanptr[ch] = samples_flt[ch] + i * 256; -+ for (; ch < full_channels; ch++) -+ s->samples_chanptr[ch] = s->extra_channels[ch - channels] + i * 256; -+ -+ dca_filter_channels(s, i); -+ -+ /* If this was marked as a DTS-ES stream we need to subtract back- */ -+ /* channel from SL & SR to remove matrixed back-channel signal */ -+ if ((s->source_pcm_res & 1) && s->xch_present) { -+ float *back_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel]]; -+ float *lt_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel - 2]]; -+ float *rt_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel - 1]]; -+ s->fdsp.vector_fmac_scalar(lt_chan, back_chan, -M_SQRT1_2, 256); -+ s->fdsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256); -+ } -+ -+ /* If stream contains XXCH, we might need to undo an embedded downmix */ -+ if (s->xxch_dmix_embedded) { -+ /* Loop over channel sets in turn */ -+ ch = num_core_channels; -+ for (chset = 0; chset < s->xxch_chset; chset++) { -+ endch = ch + s->xxch_chset_nch[chset]; -+ mask = s->xxch_dmix_embedded; -+ -+ /* undo downmix */ -+ for (j = ch; j < endch; j++) { -+ if (mask & (1 << j)) { /* this channel has been mixed-out */ -+ src_chan = s->samples_chanptr[s->channel_order_tab[j]]; -+ for (k = 0; k < endch; k++) { -+ achan = s->channel_order_tab[k]; -+ scale = s->xxch_dmix_coeff[j][k]; -+ if (scale != 0.0) { -+ dst_chan = s->samples_chanptr[achan]; -+ s->fdsp.vector_fmac_scalar(dst_chan, src_chan, -+ -scale, 256); -+ } -+ } -+ } -+ } -+ -+ /* if a downmix has been embedded then undo the pre-scaling */ -+ if ((mask & (1 << ch)) && s->xxch_dmix_sf[chset] != 1.0f) { -+ scale = s->xxch_dmix_sf[chset]; -+ -+ for (j = 0; j < ch; j++) { -+ src_chan = s->samples_chanptr[s->channel_order_tab[j]]; -+ for (k = 0; k < 256; k++) -+ src_chan[k] *= scale; -+ } -+ -+ /* LFE channel is always part of core, scale if it exists */ -+ if (s->lfe) { -+ src_chan = s->samples_chanptr[s->lfe_index]; -+ for (k = 0; k < 256; k++) -+ src_chan[k] *= scale; -+ } -+ } -+ -+ ch = endch; -+ } -+ -+ } -+ } -+ -+ /* update lfe history */ -+ lfe_samples = 2 * s->lfe * (s->sample_blocks / 8); -+ for (i = 0; i < 2 * s->lfe * 4; i++) -+ s->lfe_data[i] = s->lfe_data[i + lfe_samples]; -+ -+ *got_frame_ptr = 1; -+ -+ return buf_size; -+} -+ -+ -+ -+/** -+ * DCA initialization -+ * -+ * @param avctx pointer to the AVCodecContext -+ */ -+ -+static av_cold int dca_decode_init(AVCodecContext *avctx) -+{ -+ DCAContext *s = avctx->priv_data; -+ -+ s->avctx = avctx; -+ dca_init_vlcs(); -+ -+ avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); -+ ff_mdct_init(&s->imdct, 6, 1, 1.0); -+ ff_synth_filter_init(&s->synth); -+ ff_dcadsp_init(&s->dcadsp); -+ ff_fmt_convert_init(&s->fmt_conv, avctx); -+ -+ avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; -+ -+ /* allow downmixing to stereo */ -+ if (avctx->channels > 0 && avctx->request_channels < avctx->channels && -+ avctx->request_channels == 2) { -+ avctx->channels = avctx->request_channels; -+ } -+ -+ return 0; -+} -+ -+static av_cold int dca_decode_end(AVCodecContext *avctx) -+{ -+ DCAContext *s = avctx->priv_data; -+ ff_mdct_end(&s->imdct); -+ av_freep(&s->extra_channels_buffer); -+ return 0; -+} -+ -+static const AVProfile profiles[] = { -+ { FF_PROFILE_DTS, "DTS" }, -+ { FF_PROFILE_DTS_ES, "DTS-ES" }, -+ { FF_PROFILE_DTS_96_24, "DTS 96/24" }, -+ { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" }, -+ { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" }, -+ { FF_PROFILE_UNKNOWN }, -+}; -+ -+AVCodec ff_dca_decoder = { -+ .name = "dca", -+ .type = AVMEDIA_TYPE_AUDIO, -+ .id = AV_CODEC_ID_DTS, -+ .priv_data_size = sizeof(DCAContext), -+ .init = dca_decode_init, -+ .decode = dca_decode_frame, -+ .close = dca_decode_end, -+ .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"), -+ .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1, -+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, -+ AV_SAMPLE_FMT_NONE }, -+ .profiles = NULL_IF_CONFIG_SMALL(profiles), -+}; -diff --git a/libavcodec/fmtconvert.c b/libavcodec/fmtconvert.c -index c03117c..fab92e2 100644 ---- a/libavcodec/fmtconvert.c -+++ b/libavcodec/fmtconvert.c -@@ -29,6 +29,12 @@ static void int32_to_float_fmul_scalar_c(float *dst, const int *src, float mul, - dst[i] = src[i] * mul; - } - -+static void int32_to_float_fmul_scalar_array_c(FmtConvertContext *c, float *dst, const int *src, float *mul, int len){ -+ int i; -+ for(i=0; iint32_to_float_fmul_scalar(dst, src, *mul++, 8); -+} -+ - static av_always_inline int float_to_int16_one(const float *src){ - return av_clip_int16(lrintf(*src)); - } -@@ -78,6 +84,7 @@ void ff_float_interleave_c(float *dst, const float **src, unsigned int len, - av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx) - { - c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c; -+ c->int32_to_float_fmul_scalar_array = int32_to_float_fmul_scalar_array_c; - c->float_to_int16 = float_to_int16_c; - c->float_to_int16_interleave = float_to_int16_interleave_c; - c->float_interleave = ff_float_interleave_c; -diff --git a/libavcodec/fmtconvert.h b/libavcodec/fmtconvert.h -index c058475..ce44615 100644 ---- a/libavcodec/fmtconvert.h -+++ b/libavcodec/fmtconvert.h -@@ -38,6 +38,20 @@ - void (*int32_to_float_fmul_scalar)(float *dst, const int *src, float mul, int len); - - /** -+ * Convert an array of int32_t to float and multiply by a float value from another array, -+ * stepping along the float array once for each 8 integers. -+ * @param c pointer to FmtConvertContext. -+ * @param dst destination array of float. -+ * constraints: 16-byte aligned -+ * @param src source array of int32_t. -+ * constraints: 16-byte aligned -+ * @param mul source array of float multipliers. -+ * @param len number of elements to convert. -+ * constraints: multiple of 8 -+ */ -+ void (*int32_to_float_fmul_scalar_array)(struct FmtConvertContext *c, float *dst, const int *src, float *mul, int len); -+ -+ /** - * Convert an array of float to an array of int16_t. - * - * Convert floats from in the range [-32768.0,32767.0] to ints --- -1.8.1.6 - - -From a54cb0a8b8e3fe207dfd0652cf339d988329f591 Mon Sep 17 00:00:00 2001 -From: Ben Avison -Date: Thu, 27 Jun 2013 23:11:44 +0100 -Subject: [PATCH 53/55] Add VFP-accelerated version of imdct_half - ---- - libavcodec/arm/Makefile | 1 + - libavcodec/arm/fft_init_arm.c | 6 + - libavcodec/arm/mdct_vfp.S | 193 +++++++++++++++++++++++++++ - libavcodec/arm/synth_filter_vfp.S | 2 +- - 4 files changed, 201 insertions(+), 1 deletion(-) - create mode 100644 libavcodec/arm/mdct_vfp.S - -diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile -index b8b4df2..f6e683a 100644 ---- a/libavcodec/arm/Makefile -+++ b/libavcodec/arm/Makefile -@@ -37,6 +37,7 @@ OBJS-$(HAVE_ARMV6) += arm/dsputil_init_armv6.o \ - $(ARMV6-OBJS-yes) - - VFP-OBJS-$(HAVE_ARMV6) += arm/fmtconvert_vfp.o \ -+ arm/mdct_vfp.o \ - arm/synth_filter_vfp.o - - OBJS-$(HAVE_ARMVFP) += arm/dsputil_vfp.o \ -diff --git a/libavcodec/arm/fft_init_arm.c b/libavcodec/arm/fft_init_arm.c -index 605b3dd..baed753 100644 ---- a/libavcodec/arm/fft_init_arm.c -+++ b/libavcodec/arm/fft_init_arm.c -@@ -25,6 +25,8 @@ - void ff_fft_permute_neon(FFTContext *s, FFTComplex *z); - void ff_fft_calc_neon(FFTContext *s, FFTComplex *z); - -+void ff_imdct_half_vfp(FFTContext *s, FFTSample *output, const FFTSample *input); -+ - void ff_imdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input); - void ff_imdct_half_neon(FFTContext *s, FFTSample *output, const FFTSample *input); - void ff_mdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input); -@@ -46,6 +48,10 @@ void ff_synth_filter_float_neon(FFTContext *imdct, - av_cold void ff_fft_init_arm(FFTContext *s) - { - if (HAVE_NEON) { -+ if (HAVE_ARMVFP) { -+ s->imdct_half = ff_imdct_half_vfp; -+ } -+ - s->fft_permute = ff_fft_permute_neon; - s->fft_calc = ff_fft_calc_neon; - #if CONFIG_MDCT -diff --git a/libavcodec/arm/mdct_vfp.S b/libavcodec/arm/mdct_vfp.S -new file mode 100644 -index 0000000..2e2126e ---- /dev/null -+++ b/libavcodec/arm/mdct_vfp.S -@@ -0,0 +1,193 @@ -+/* -+ * Copyright (c) 2013 RISC OS Open Ltd -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ * -+ * Author: Ben Avison -+ */ -+ -+#include "libavcodec/arm/asm.S" -+ -+CONTEXT .req a1 -+ORIGOUT .req a2 -+IN .req a3 -+OUT .req v1 -+REVTAB .req v2 -+TCOS .req v3 -+TSIN .req v4 -+OLDFPSCR .req v5 -+J0 .req a2 -+J1 .req a4 -+J2 .req ip -+J3 .req lr -+ -+.macro prerotation_innerloop -+ .set trig_lo, k -+ .set trig_hi, n4 - k - 2 -+ .set in_lo, trig_lo * 2 -+ .set in_hi, trig_hi * 2 -+ vldr d8, [TCOS, #trig_lo*4] @ s16,s17 -+ vldr d9, [TCOS, #trig_hi*4] @ s18,s19 -+ vldr s0, [IN, #in_hi*4 + 12] -+ vldr s1, [IN, #in_hi*4 + 4] -+ vldr s2, [IN, #in_lo*4 + 12] -+ vldr s3, [IN, #in_lo*4 + 4] -+ vmul.f s8, s0, s16 @ vector operation -+ vldr d10, [TSIN, #trig_lo*4] @ s20,s21 -+ vldr d11, [TSIN, #trig_hi*4] @ s22,s23 -+ vldr s4, [IN, #in_lo*4] -+ vldr s5, [IN, #in_lo*4 + 8] -+ vldr s6, [IN, #in_hi*4] -+ vldr s7, [IN, #in_hi*4 + 8] -+ ldr J0, [REVTAB, #trig_lo*2] -+ vmul.f s12, s0, s20 @ vector operation -+ ldr J2, [REVTAB, #trig_hi*2] -+ mov J1, J0, lsr #16 -+ and J0, J0, #255 @ halfword value will be < n4 -+ vmls.f s8, s4, s20 @ vector operation -+ mov J3, J2, lsr #16 -+ and J2, J2, #255 @ halfword value will be < n4 -+ add J0, OUT, J0, lsl #3 -+ vmla.f s12, s4, s16 @ vector operation -+ add J1, OUT, J1, lsl #3 -+ add J2, OUT, J2, lsl #3 -+ add J3, OUT, J3, lsl #3 -+ vstr s8, [J0] -+ vstr s9, [J1] -+ vstr s10, [J2] -+ vstr s11, [J3] -+ vstr s12, [J0, #4] -+ vstr s13, [J1, #4] -+ vstr s14, [J2, #4] -+ vstr s15, [J3, #4] -+ .set k, k + 2 -+.endm -+ -+.macro postrotation_innerloop tail, head -+ .set trig_lo_head, n8 - k - 2 -+ .set trig_hi_head, n8 + k -+ .set out_lo_head, trig_lo_head * 2 -+ .set out_hi_head, trig_hi_head * 2 -+ .set trig_lo_tail, n8 - (k - 2) - 2 -+ .set trig_hi_tail, n8 + (k - 2) -+ .set out_lo_tail, trig_lo_tail * 2 -+ .set out_hi_tail, trig_hi_tail * 2 -+ .if (k & 2) == 0 -+ TCOS_D0_HEAD .req d10 @ s20,s21 -+ TCOS_D1_HEAD .req d11 @ s22,s23 -+ TCOS_S0_TAIL .req s24 -+ .else -+ TCOS_D0_HEAD .req d12 @ s24,s25 -+ TCOS_D1_HEAD .req d13 @ s26,s27 -+ TCOS_S0_TAIL .req s20 -+ .endif -+ .ifnc "\tail","" -+ vmls.f s8, s0, TCOS_S0_TAIL @ vector operation -+ .endif -+ .ifnc "\head","" -+ vldr d8, [TSIN, #trig_lo_head*4] @ s16,s17 -+ vldr d9, [TSIN, #trig_hi_head*4] @ s18,s19 -+ vldr TCOS_D0_HEAD, [TCOS, #trig_lo_head*4] -+ .endif -+ .ifnc "\tail","" -+ vmla.f s12, s4, TCOS_S0_TAIL @ vector operation -+ .endif -+ .ifnc "\head","" -+ vldr s0, [OUT, #out_lo_head*4] -+ vldr s1, [OUT, #out_lo_head*4 + 8] -+ vldr s2, [OUT, #out_hi_head*4] -+ vldr s3, [OUT, #out_hi_head*4 + 8] -+ vldr s4, [OUT, #out_lo_head*4 + 4] -+ vldr s5, [OUT, #out_lo_head*4 + 12] -+ vldr s6, [OUT, #out_hi_head*4 + 4] -+ vldr s7, [OUT, #out_hi_head*4 + 12] -+ .endif -+ .ifnc "\tail","" -+ vstr s8, [OUT, #out_lo_tail*4] -+ vstr s9, [OUT, #out_lo_tail*4 + 8] -+ vstr s10, [OUT, #out_hi_tail*4] -+ vstr s11, [OUT, #out_hi_tail*4 + 8] -+ .endif -+ .ifnc "\head","" -+ vmul.f s8, s4, s16 @ vector operation -+ .endif -+ .ifnc "\tail","" -+ vstr s12, [OUT, #out_hi_tail*4 + 12] -+ vstr s13, [OUT, #out_hi_tail*4 + 4] -+ vstr s14, [OUT, #out_lo_tail*4 + 12] -+ vstr s15, [OUT, #out_lo_tail*4 + 4] -+ .endif -+ .ifnc "\head","" -+ vmul.f s12, s0, s16 @ vector operation -+ vldr TCOS_D1_HEAD, [TCOS, #trig_hi_head*4] -+ .endif -+ .unreq TCOS_D0_HEAD -+ .unreq TCOS_D1_HEAD -+ .unreq TCOS_S0_TAIL -+ .ifnc "\head","" -+ .set k, k + 2 -+ .endif -+.endm -+ -+ -+/* void ff_imdct_half_vfp(FFTContext *s, -+ * FFTSample *output, -+ * const FFTSample *input) -+ */ -+function ff_imdct_half_vfp, export=1 -+ ldr ip, [CONTEXT, #5*4] @ mdct_bits -+ teq ip, #6 -+ bne ff_imdct_half_c @ only case currently accelerated is the one used by DCA -+ -+ .set n, 1<<6 -+ .set n2, n/2 -+ .set n4, n/4 -+ .set n8, n/8 -+ -+ push {v1-v5,lr} -+ vpush {s16-s27} -+ vmrs OLDFPSCR, FPSCR -+ ldr lr, =0x03030000 @ RunFast mode, short vectors of length 4, stride 1 -+ vmsr FPSCR, lr -+ mov OUT, ORIGOUT -+ ldr REVTAB, [CONTEXT, #2*4] -+ ldr TCOS, [CONTEXT, #6*4] -+ ldr TSIN, [CONTEXT, #7*4] -+ -+ .set k, 0 -+ .rept n8/2 -+ prerotation_innerloop -+ .endr -+ -+ vmsr FPSCR, OLDFPSCR -+ mov ORIGOUT, OUT -+ ldr ip, [CONTEXT, #9*4] -+ blx ip @ s->fft_calc(s, output) -+ ldr lr, =0x03030000 @ RunFast mode, short vectors of length 4, stride 1 -+ vmsr FPSCR, lr -+ -+ .set k, 0 -+ postrotation_innerloop , head -+ .rept n8/2 - 1 -+ postrotation_innerloop tail, head -+ .endr -+ postrotation_innerloop tail -+ -+ vmsr FPSCR, OLDFPSCR -+ vpop {s16-s27} -+ pop {v1-v5,pc} -+endfunc -diff --git a/libavcodec/arm/synth_filter_vfp.S b/libavcodec/arm/synth_filter_vfp.S -index 8c54267..40bf2c4 100644 ---- a/libavcodec/arm/synth_filter_vfp.S -+++ b/libavcodec/arm/synth_filter_vfp.S -@@ -133,7 +133,7 @@ function ff_synth_filter_float_vfp, export=1 - str lr, [P_SB_OFF] @ rotate offset, modulo buffer size, ready for next call - ldr a3, [sp, #(16+6+2)*4] @ fetch in from stack, to pass to imdct_half - VFP vmov s16, SCALE @ imdct_half is free to corrupt s0, but it contains one of our arguments in hardfp case -- bl ff_imdct_half_c -+ bl ff_imdct_half_vfp - VFP vmov SCALE, s16 - - vmrs OLDFPSCR, FPSCR --- -1.8.1.6 - - -From 872db4f60fd2314cab83eeddf72a46a53708bf62 Mon Sep 17 00:00:00 2001 -From: Ben Avison -Date: Fri, 28 Jun 2013 21:21:06 +0100 -Subject: [PATCH 54/55] Add VFP_accelerated version of dca_lfe_fir - ---- - libavcodec/arm/Makefile | 3 +- - libavcodec/arm/dcadsp_init_arm.c | 4 + - libavcodec/arm/dcadsp_vfp.S | 189 ++++++++++++++++++++++++++++ - 3 files changed, 195 insertions(+), 1 deletion(-) - create mode 100644 libavcodec/arm/dcadsp_vfp.S - -diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile -index f6e683a..ad1ae07 100644 ---- a/libavcodec/arm/Makefile -+++ b/libavcodec/arm/Makefile -@@ -36,7 +36,8 @@ OBJS-$(HAVE_ARMV6) += arm/dsputil_init_armv6.o \ - arm/simple_idct_armv6.o \ - $(ARMV6-OBJS-yes) - --VFP-OBJS-$(HAVE_ARMV6) += arm/fmtconvert_vfp.o \ -+VFP-OBJS-$(HAVE_ARMV6) += arm/dcadsp_vfp.o \ -+ arm/fmtconvert_vfp.o \ - arm/mdct_vfp.o \ - arm/synth_filter_vfp.o - -diff --git a/libavcodec/arm/dcadsp_init_arm.c b/libavcodec/arm/dcadsp_init_arm.c -index 5663cd7..d62fc75 100644 ---- a/libavcodec/arm/dcadsp_init_arm.c -+++ b/libavcodec/arm/dcadsp_init_arm.c -@@ -22,11 +22,15 @@ - #include "libavutil/attributes.h" - #include "libavcodec/dcadsp.h" - -+void ff_dca_lfe_fir_vfp(float *out, const float *in, const float *coefs, -+ int decifactor, float scale); - void ff_dca_lfe_fir_neon(float *out, const float *in, const float *coefs, - int decifactor, float scale); - - void av_cold ff_dcadsp_init_arm(DCADSPContext *s) - { -+ if (HAVE_ARMVFP) -+ s->lfe_fir = ff_dca_lfe_fir_vfp; - if (HAVE_NEON) - s->lfe_fir = ff_dca_lfe_fir_neon; - } -diff --git a/libavcodec/arm/dcadsp_vfp.S b/libavcodec/arm/dcadsp_vfp.S -new file mode 100644 -index 0000000..606e4af ---- /dev/null -+++ b/libavcodec/arm/dcadsp_vfp.S -@@ -0,0 +1,189 @@ -+/* -+ * Copyright (c) 2013 RISC OS Open Ltd -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ * -+ * Author: Ben Avison -+ */ -+ -+#include "libavcodec/arm/asm.S" -+ -+POUT .req a1 -+PIN .req a2 -+PCOEF .req a3 -+DECIFACTOR .req a4 -+OLDFPSCR .req a4 -+COUNTER .req ip -+ -+SCALE32 .req s28 @ use vector of 4 in place of 9th scalar when decifactor=32 / JMAX=8 -+SCALE64 .req s0 @ spare register in scalar bank when decifactor=64 / JMAX=4 -+IN0 .req s4 -+IN1 .req s5 -+IN2 .req s6 -+IN3 .req s7 -+IN4 .req s0 -+IN5 .req s1 -+IN6 .req s2 -+IN7 .req s3 -+COEF0 .req s8 @ coefficient elements -+COEF1 .req s9 -+COEF2 .req s10 -+COEF3 .req s11 -+COEF4 .req s12 -+COEF5 .req s13 -+COEF6 .req s14 -+COEF7 .req s15 -+ACCUM0 .req s16 @ double-buffered multiply-accumulate results -+ACCUM4 .req s20 -+POST0 .req s24 @ do long-latency post-multiply in this vector in parallel -+POST1 .req s25 -+POST2 .req s26 -+POST3 .req s27 -+ -+ -+.macro inner_loop decifactor, dir, tail, head -+ .ifc "\dir","up" -+ .set X, 0 -+ .set Y, 4 -+ .else -+ .set X, 4*JMAX*4 - 4 -+ .set Y, -4 -+ .endif -+ .ifnc "\head","" -+ vldr COEF0, [PCOEF, #X + (0*JMAX + 0) * Y] -+ vldr COEF1, [PCOEF, #X + (1*JMAX + 0) * Y] -+ vldr COEF2, [PCOEF, #X + (2*JMAX + 0) * Y] -+ vldr COEF3, [PCOEF, #X + (3*JMAX + 0) * Y] -+ .endif -+ .ifnc "\tail","" -+ vadd.f POST0, ACCUM0, ACCUM4 @ vector operation -+ .endif -+ .ifnc "\head","" -+ vmul.f ACCUM0, COEF0, IN0 @ vector = vector * scalar -+ vldr COEF4, [PCOEF, #X + (0*JMAX + 1) * Y] -+ vldr COEF5, [PCOEF, #X + (1*JMAX + 1) * Y] -+ vldr COEF6, [PCOEF, #X + (2*JMAX + 1) * Y] -+ .endif -+ .ifnc "\tail","" -+ vmul.f POST0, POST0, SCALE\decifactor @ vector operation (SCALE may be scalar) -+ .endif -+ .ifnc "\head","" -+ vldr COEF7, [PCOEF, #X + (3*JMAX + 1) * Y] -+ .ifc "\tail","" -+ vmul.f ACCUM4, COEF4, IN1 @ vector operation -+ .endif -+ vldr COEF0, [PCOEF, #X + (0*JMAX + 2) * Y] -+ vldr COEF1, [PCOEF, #X + (1*JMAX + 2) * Y] -+ .ifnc "\tail","" -+ vmul.f ACCUM4, COEF4, IN1 @ vector operation -+ .endif -+ vldr COEF2, [PCOEF, #X + (2*JMAX + 2) * Y] -+ vldr COEF3, [PCOEF, #X + (3*JMAX + 2) * Y] -+ .endif -+ .ifnc "\tail","" -+ vstmia POUT!, {POST0-POST3} -+ .endif -+ .ifnc "\head","" -+ vmla.f ACCUM0, COEF0, IN2 @ vector = vector * scalar -+ vldr COEF4, [PCOEF, #X + (0*JMAX + 3) * Y] -+ vldr COEF5, [PCOEF, #X + (1*JMAX + 3) * Y] -+ vldr COEF6, [PCOEF, #X + (2*JMAX + 3) * Y] -+ vldr COEF7, [PCOEF, #X + (3*JMAX + 3) * Y] -+ vmla.f ACCUM4, COEF4, IN3 @ vector = vector * scalar -+ .if \decifactor == 32 -+ vldr COEF0, [PCOEF, #X + (0*JMAX + 4) * Y] -+ vldr COEF1, [PCOEF, #X + (1*JMAX + 4) * Y] -+ vldr COEF2, [PCOEF, #X + (2*JMAX + 4) * Y] -+ vldr COEF3, [PCOEF, #X + (3*JMAX + 4) * Y] -+ vmla.f ACCUM0, COEF0, IN4 @ vector = vector * scalar -+ vldr COEF4, [PCOEF, #X + (0*JMAX + 5) * Y] -+ vldr COEF5, [PCOEF, #X + (1*JMAX + 5) * Y] -+ vldr COEF6, [PCOEF, #X + (2*JMAX + 5) * Y] -+ vldr COEF7, [PCOEF, #X + (3*JMAX + 5) * Y] -+ vmla.f ACCUM4, COEF4, IN5 @ vector = vector * scalar -+ vldr COEF0, [PCOEF, #X + (0*JMAX + 6) * Y] -+ vldr COEF1, [PCOEF, #X + (1*JMAX + 6) * Y] -+ vldr COEF2, [PCOEF, #X + (2*JMAX + 6) * Y] -+ vldr COEF3, [PCOEF, #X + (3*JMAX + 6) * Y] -+ vmla.f ACCUM0, COEF0, IN6 @ vector = vector * scalar -+ vldr COEF4, [PCOEF, #X + (0*JMAX + 7) * Y] -+ vldr COEF5, [PCOEF, #X + (1*JMAX + 7) * Y] -+ vldr COEF6, [PCOEF, #X + (2*JMAX + 7) * Y] -+ vldr COEF7, [PCOEF, #X + (3*JMAX + 7) * Y] -+ vmla.f ACCUM4, COEF4, IN7 @ vector = vector * scalar -+ .endif -+ .endif -+.endm -+ -+.macro dca_lfe_fir decifactor -+ .if \decifactor == 32 -+ .set JMAX, 8 -+ vpush {s16-s31} -+ vmov SCALE32, s0 @ duplicate scalar across vector -+ vldr IN4, [PIN, #-4*4] -+ vldr IN5, [PIN, #-5*4] -+ vldr IN6, [PIN, #-6*4] -+ vldr IN7, [PIN, #-7*4] -+ .else -+ .set JMAX, 4 -+ vpush {s16-s27} -+ .endif -+ -+ mov COUNTER, #\decifactor/4 - 1 -+ inner_loop \decifactor, up,, head -+1: add PCOEF, PCOEF, #4*JMAX*4 -+ subs COUNTER, COUNTER, #1 -+ inner_loop \decifactor, up, tail, head -+ bne 1b -+ inner_loop \decifactor, up, tail -+ -+ mov COUNTER, #\decifactor/4 - 1 -+ inner_loop \decifactor, down,, head -+1: sub PCOEF, PCOEF, #4*JMAX*4 -+ subs COUNTER, COUNTER, #1 -+ inner_loop \decifactor, down, tail, head -+ bne 1b -+ inner_loop \decifactor, down, tail -+ -+ .if \decifactor == 32 -+ vpop {s16-s31} -+ .else -+ vpop {s16-s27} -+ .endif -+ vmsr FPSCR, OLDFPSCR -+ bx lr -+.endm -+ -+ -+/* void ff_dca_lfe_fir_vfp(float *out, const float *in, const float *coefs, -+ * int decifactor, float scale) -+ */ -+function ff_dca_lfe_fir_vfp, export=1 -+ teq DECIFACTOR, #32 -+ vmrs OLDFPSCR, FPSCR -+ ldr ip, =0x03030000 @ RunFast mode, short vectors of length 4, stride 1 -+ vmsr FPSCR, ip -+NOVFP vldr s0, [sp] -+ vldr IN0, [PIN, #-0*4] -+ vldr IN1, [PIN, #-1*4] -+ vldr IN2, [PIN, #-2*4] -+ vldr IN3, [PIN, #-3*4] -+ beq 32f -+64: dca_lfe_fir 64 -+ .ltorg -+32: dca_lfe_fir 32 -+endfunc --- -1.8.1.6 - - -From 59230eeb1c1ac9bbb3089fd86172d5fafbdebe94 Mon Sep 17 00:00:00 2001 -From: Ben Avison -Date: Tue, 9 Jul 2013 17:44:50 +0100 -Subject: [PATCH 55/55] Add VFP-accelerated version of fft16 - ---- - libavcodec/arm/Makefile | 1 + - libavcodec/arm/fft_vfp.S | 299 +++++++++++++++++++++++++++++++++++ - libavcodec/arm/mdct_vfp.S | 5 +- - 3 files changed, 302 insertions(+), 3 deletions(-) - create mode 100644 libavcodec/arm/fft_vfp.S - -diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile -index ad1ae07..798dfe3 100644 ---- a/libavcodec/arm/Makefile -+++ b/libavcodec/arm/Makefile -@@ -37,6 +37,7 @@ OBJS-$(HAVE_ARMV6) += arm/dsputil_init_armv6.o \ - $(ARMV6-OBJS-yes) - - VFP-OBJS-$(HAVE_ARMV6) += arm/dcadsp_vfp.o \ -+ arm/fft_vfp.o \ - arm/fmtconvert_vfp.o \ - arm/mdct_vfp.o \ - arm/synth_filter_vfp.o -diff --git a/libavcodec/arm/fft_vfp.S b/libavcodec/arm/fft_vfp.S -new file mode 100644 -index 0000000..a7106ea ---- /dev/null -+++ b/libavcodec/arm/fft_vfp.S -@@ -0,0 +1,299 @@ -+/* -+ * Copyright (c) 2013 RISC OS Open Ltd -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ * -+ * Author: Ben Avison -+ */ -+ -+#include "libavcodec/arm/asm.S" -+ -+@ TODO: * FFTs wider than 16 -+@ * dispatch code -+ -+function fft4_vfp -+ vldr d0, [a1, #0*2*4] @ s0,s1 = z[0] -+ vldr d4, [a1, #1*2*4] @ s8,s9 = z[1] -+ vldr d1, [a1, #2*2*4] @ s2,s3 = z[2] -+ vldr d5, [a1, #3*2*4] @ s10,s11 = z[3] -+ @ stall -+ vadd.f s12, s0, s8 @ i0 -+ vadd.f s13, s1, s9 @ i1 -+ vadd.f s14, s2, s10 @ i2 -+ vadd.f s15, s3, s11 @ i3 -+ vsub.f s8, s0, s8 @ i4 -+ vsub.f s9, s1, s9 @ i5 -+ vsub.f s10, s2, s10 @ i6 -+ vsub.f s11, s3, s11 @ i7 -+ @ stall -+ @ stall -+ vadd.f s0, s12, s14 @ z[0].re -+ vsub.f s4, s12, s14 @ z[2].re -+ vadd.f s1, s13, s15 @ z[0].im -+ vsub.f s5, s13, s15 @ z[2].im -+ vadd.f s7, s9, s10 @ z[3].im -+ vsub.f s3, s9, s10 @ z[1].im -+ vadd.f s2, s8, s11 @ z[1].re -+ vsub.f s6, s8, s11 @ z[3].re -+ @ stall -+ @ stall -+ vstr d0, [a1, #0*2*4] -+ vstr d2, [a1, #2*2*4] -+ @ stall -+ @ stall -+ vstr d1, [a1, #1*2*4] -+ vstr d3, [a1, #3*2*4] -+ -+ bx lr -+endfunc -+ -+.macro macro_fft8_head -+ @ FFT4 -+ vldr d4, [a1, #0 * 2*4] -+ vldr d6, [a1, #1 * 2*4] -+ vldr d5, [a1, #2 * 2*4] -+ vldr d7, [a1, #3 * 2*4] -+ @ BF -+ vldr d12, [a1, #4 * 2*4] -+ vadd.f s16, s8, s12 @ vector op -+ vldr d14, [a1, #5 * 2*4] -+ vldr d13, [a1, #6 * 2*4] -+ vldr d15, [a1, #7 * 2*4] -+ vsub.f s20, s8, s12 @ vector op -+ vadd.f s0, s16, s18 -+ vsub.f s2, s16, s18 -+ vadd.f s1, s17, s19 -+ vsub.f s3, s17, s19 -+ vadd.f s7, s21, s22 -+ vsub.f s5, s21, s22 -+ vadd.f s4, s20, s23 -+ vsub.f s6, s20, s23 -+ vsub.f s20, s24, s28 @ vector op -+ vstr d0, [a1, #0 * 2*4] @ transfer s0-s7 to s24-s31 via memory -+ vstr d1, [a1, #1 * 2*4] -+ vldr s0, cos1pi4 -+ vadd.f s16, s24, s28 @ vector op -+ vstr d2, [a1, #2 * 2*4] -+ vstr d3, [a1, #3 * 2*4] -+ vldr d12, [a1, #0 * 2*4] -+ @ TRANSFORM -+ vmul.f s20, s20, s0 @ vector x scalar op -+ vldr d13, [a1, #1 * 2*4] -+ vldr d14, [a1, #2 * 2*4] -+ vldr d15, [a1, #3 * 2*4] -+ @ BUTTERFLIES -+ vadd.f s0, s18, s16 -+ vadd.f s1, s17, s19 -+ vsub.f s2, s17, s19 -+ vsub.f s3, s18, s16 -+ vadd.f s4, s21, s20 -+ vsub.f s5, s21, s20 -+ vadd.f s6, s22, s23 -+ vsub.f s7, s22, s23 -+ vadd.f s8, s0, s24 @ vector op -+ vstr d0, [a1, #0 * 2*4] @ transfer s0-s3 to s12-s15 via memory -+ vstr d1, [a1, #1 * 2*4] -+ vldr d6, [a1, #0 * 2*4] -+ vldr d7, [a1, #1 * 2*4] -+ vadd.f s1, s5, s6 -+ vadd.f s0, s7, s4 -+ vsub.f s2, s5, s6 -+ vsub.f s3, s7, s4 -+ vsub.f s12, s24, s12 @ vector op -+ vsub.f s5, s29, s1 -+ vsub.f s4, s28, s0 -+ vsub.f s6, s30, s2 -+ vsub.f s7, s31, s3 -+ vadd.f s16, s0, s28 @ vector op -+ vstr d6, [a1, #4 * 2*4] -+ vstr d7, [a1, #6 * 2*4] -+ vstr d4, [a1, #0 * 2*4] -+ vstr d5, [a1, #2 * 2*4] -+ vstr d2, [a1, #5 * 2*4] -+ vstr d3, [a1, #7 * 2*4] -+.endm -+ -+.macro macro_fft8_tail -+ vstr d8, [a1, #1 * 2*4] -+ vstr d9, [a1, #3 * 2*4] -+.endm -+ -+function fft8_vfp -+ ldr a3, =0x03030000 @ RunFast mode, vector length 4, stride 1 -+ vmrs a2, FPSCR -+ vmsr FPSCR, a3 -+ vpush {s16-s31} -+ -+ macro_fft8_head -+ macro_fft8_tail -+ -+ vpop {s16-s31} -+ vmsr FPSCR, a2 -+ bx lr -+endfunc -+ -+.align 3 -+cos1pi4: @ cos(1*pi/4) = sqrt(2) -+ .float 0.707106769084930419921875 -+cos1pi8: @ cos(1*pi/8) = sqrt(2+sqrt(2))/2 -+ .float 0.92387950420379638671875 -+cos3pi8: @ cos(2*pi/8) = sqrt(2-sqrt(2))/2 -+ .float 0.3826834261417388916015625 -+ -+function ff_fft16_vfp, export=1 -+ ldr a3, =0x03030000 @ RunFast mode, vector length 4, stride 1 -+ vmrs a2, FPSCR -+ vmsr FPSCR, a3 -+ vpush {s16-s31} -+ -+ macro_fft8_head -+ @ FFT4(z+8) -+ vldr d10, [a1, #8 * 2*4] -+ vldr d12, [a1, #9 * 2*4] -+ vldr d11, [a1, #10 * 2*4] -+ vldr d13, [a1, #11 * 2*4] -+ macro_fft8_tail -+ vadd.f s16, s20, s24 @ vector op -+ @ FFT4(z+12) -+ vldr d4, [a1, #12 * 2*4] -+ vldr d6, [a1, #13 * 2*4] -+ vldr d5, [a1, #14 * 2*4] -+ vsub.f s20, s20, s24 @ vector op -+ vldr d7, [a1, #15 * 2*4] -+ vadd.f s0, s16, s18 -+ vsub.f s4, s16, s18 -+ vadd.f s1, s17, s19 -+ vsub.f s5, s17, s19 -+ vadd.f s7, s21, s22 -+ vsub.f s3, s21, s22 -+ vadd.f s2, s20, s23 -+ vsub.f s6, s20, s23 -+ vadd.f s16, s8, s12 @ vector op -+ vstr d0, [a1, #8 * 2*4] -+ vstr d2, [a1, #10 * 2*4] -+ vstr d1, [a1, #9 * 2*4] -+ vsub.f s20, s8, s12 -+ vstr d3, [a1, #11 * 2*4] -+ @ TRANSFORM(z[2],z[6],z[10],z[14],cos1pi4,cos1pi4) -+ vldr d12, [a1, #10 * 2*4] -+ vadd.f s0, s16, s18 -+ vadd.f s1, s17, s19 -+ vsub.f s6, s16, s18 -+ vsub.f s7, s17, s19 -+ vsub.f s3, s21, s22 -+ vadd.f s2, s20, s23 -+ vadd.f s5, s21, s22 -+ vsub.f s4, s20, s23 -+ vstr d0, [a1, #12 * 2*4] -+ vmov s0, s6 -+ @ TRANSFORM(z[1],z[5],z[9],z[13],cos1pi8,cos3pi8) -+ vldr d6, [a1, #9 * 2*4] -+ vstr d1, [a1, #13 * 2*4] -+ vldr d1, cos1pi4 @ s2 = cos1pi4, s3 = cos1pi8 -+ vstr d2, [a1, #15 * 2*4] -+ vldr d7, [a1, #13 * 2*4] -+ vadd.f s4, s25, s24 -+ vsub.f s5, s25, s24 -+ vsub.f s6, s0, s7 -+ vadd.f s7, s0, s7 -+ vmul.f s20, s12, s3 @ vector op -+ @ TRANSFORM(z[3],z[7],z[11],z[15],cos3pi8,cos1pi8) -+ vldr d4, [a1, #11 * 2*4] -+ vldr d5, [a1, #15 * 2*4] -+ vldr s1, cos3pi8 -+ vmul.f s24, s4, s2 @ vector * scalar op -+ vmul.f s28, s12, s1 @ vector * scalar op -+ vmul.f s12, s8, s1 @ vector * scalar op -+ vadd.f s4, s20, s29 -+ vsub.f s5, s21, s28 -+ vsub.f s6, s22, s31 -+ vadd.f s7, s23, s30 -+ vmul.f s8, s8, s3 @ vector * scalar op -+ vldr d8, [a1, #1 * 2*4] -+ vldr d9, [a1, #5 * 2*4] -+ vldr d10, [a1, #3 * 2*4] -+ vldr d11, [a1, #7 * 2*4] -+ vldr d14, [a1, #2 * 2*4] -+ vadd.f s0, s6, s4 -+ vadd.f s1, s5, s7 -+ vsub.f s2, s5, s7 -+ vsub.f s3, s6, s4 -+ vadd.f s4, s12, s9 -+ vsub.f s5, s13, s8 -+ vsub.f s6, s14, s11 -+ vadd.f s7, s15, s10 -+ vadd.f s12, s0, s16 @ vector op -+ vstr d0, [a1, #1 * 2*4] -+ vstr d1, [a1, #5 * 2*4] -+ vldr d4, [a1, #1 * 2*4] -+ vldr d5, [a1, #5 * 2*4] -+ vadd.f s0, s6, s4 -+ vadd.f s1, s5, s7 -+ vsub.f s2, s5, s7 -+ vsub.f s3, s6, s4 -+ vsub.f s8, s16, s8 @ vector op -+ vstr d6, [a1, #1 * 2*4] -+ vstr d7, [a1, #5 * 2*4] -+ vldr d15, [a1, #6 * 2*4] -+ vsub.f s4, s20, s0 -+ vsub.f s5, s21, s1 -+ vsub.f s6, s22, s2 -+ vsub.f s7, s23, s3 -+ vadd.f s20, s0, s20 @ vector op -+ vstr d4, [a1, #9 * 2*4] -+ @ TRANSFORM_ZERO(z[0],z[4],z[8],z[12]) -+ vldr d6, [a1, #8 * 2*4] -+ vstr d5, [a1, #13 * 2*4] -+ vldr d7, [a1, #12 * 2*4] -+ vstr d2, [a1, #11 * 2*4] -+ vldr d8, [a1, #0 * 2*4] -+ vstr d3, [a1, #15 * 2*4] -+ vldr d9, [a1, #4 * 2*4] -+ vadd.f s0, s26, s24 -+ vadd.f s1, s25, s27 -+ vsub.f s2, s25, s27 -+ vsub.f s3, s26, s24 -+ vadd.f s4, s14, s12 -+ vadd.f s5, s13, s15 -+ vsub.f s6, s13, s15 -+ vsub.f s7, s14, s12 -+ vadd.f s8, s0, s28 @ vector op -+ vstr d0, [a1, #3 * 2*4] -+ vstr d1, [a1, #7 * 2*4] -+ vldr d6, [a1, #3 * 2*4] -+ vldr d7, [a1, #7 * 2*4] -+ vsub.f s0, s16, s4 -+ vsub.f s1, s17, s5 -+ vsub.f s2, s18, s6 -+ vsub.f s3, s19, s7 -+ vsub.f s12, s28, s12 @ vector op -+ vadd.f s16, s4, s16 @ vector op -+ vstr d10, [a1, #3 * 2*4] -+ vstr d11, [a1, #7 * 2*4] -+ vstr d4, [a1, #2 * 2*4] -+ vstr d5, [a1, #6 * 2*4] -+ vstr d0, [a1, #8 * 2*4] -+ vstr d1, [a1, #12 * 2*4] -+ vstr d6, [a1, #10 * 2*4] -+ vstr d7, [a1, #14 * 2*4] -+ vstr d8, [a1, #0 * 2*4] -+ vstr d9, [a1, #4 * 2*4] -+ -+ vpop {s16-s31} -+ vmsr FPSCR, a2 -+ bx lr -+endfunc -diff --git a/libavcodec/arm/mdct_vfp.S b/libavcodec/arm/mdct_vfp.S -index 2e2126e..56ad48e 100644 ---- a/libavcodec/arm/mdct_vfp.S -+++ b/libavcodec/arm/mdct_vfp.S -@@ -174,9 +174,8 @@ function ff_imdct_half_vfp, export=1 - .endr - - vmsr FPSCR, OLDFPSCR -- mov ORIGOUT, OUT -- ldr ip, [CONTEXT, #9*4] -- blx ip @ s->fft_calc(s, output) -+ mov a1, OUT -+ bl ff_fft16_vfp - ldr lr, =0x03030000 @ RunFast mode, short vectors of length 4, stride 1 - vmsr FPSCR, lr - --- -1.8.1.6 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-912-Vividas-support-for-IPLEX-for-current-ffmpeg.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-912-Vividas-support-for-IPLEX-for-current-ffmpeg.patch deleted file mode 100644 index 384115fe2f..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-912-Vividas-support-for-IPLEX-for-current-ffmpeg.patch +++ /dev/null @@ -1,1569 +0,0 @@ -From ec459ccb9a7eadee41afd4da2b71a52e18dceae6 Mon Sep 17 00:00:00 2001 -From: Tomasz Jezierski -Date: Thu, 6 Sep 2012 20:14:27 +0200 -Subject: [PATCH] Vividas support for IPLEX for current ffmpeg -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Ported to current ffmpeg version -Copyright (c) 2010 Andrzej Szombierski -based on vivparse Copyright (c) 2007 Måns Rullgård ---- - libavformat/Makefile | 1 + - libavformat/allformats.c | 1 + - libavformat/vividas.c | 740 ++++++++++++++++++++++++ - patches/0110-vividas-support.patch | 770 +++++++++++++++++++++++++ - 4 files changed, 1512 insertions(+) - create mode 100644 libavformat/vividas.c - create mode 100644 patches/0110-vividas-support.patch - -diff --git a/libavformat/Makefile b/libavformat/Makefile -index bd2b17b..6642498 100644 ---- a/libavformat/Makefile -+++ b/libavformat/Makefile -@@ -315,6 +315,7 @@ OBJS-$(CONFIG_TXD_DEMUXER) += txd.o - OBJS-$(CONFIG_VC1_DEMUXER) += rawdec.o - OBJS-$(CONFIG_VC1T_DEMUXER) += vc1test.o - OBJS-$(CONFIG_VC1T_MUXER) += vc1testenc.o -+OBJS-$(CONFIG_VIVIDAS_DEMUXER) += vividas.o - OBJS-$(CONFIG_VMD_DEMUXER) += sierravmd.o - OBJS-$(CONFIG_VOC_DEMUXER) += vocdec.o voc.o - OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o -diff --git a/libavformat/allformats.c b/lib/ffmpeg/libavformat/allformats.c -index 134839f..0af5ba9 100644 ---- a/libavformat/allformats.c -+++ b/libavformat/allformats.c -@@ -232,6 +232,7 @@ void av_register_all(void) - REGISTER_DEMUXER (TTY, tty); - REGISTER_DEMUXER (VC1, vc1); - REGISTER_MUXDEMUX (VC1T, vc1t); -+ REGISTER_DEMUXER (VIVIDAS, vividas); - REGISTER_DEMUXER (VMD, vmd); - REGISTER_MUXDEMUX (VOC, voc); - REGISTER_DEMUXER (VQF, vqf); -diff --git a/libavformat/vividas.c b/libavformat/vividas.c -new file mode 100644 -index 0000000..2d3ba27 ---- /dev/null -+++ b/libavformat/vividas.c -@@ -0,0 +1,740 @@ -+/* -+ * Vividas VIV format Demuxer -+ * Copyright (c) 2010 Andrzej Szombierski -+ * based on vivparse Copyright (c) 2007 Måns Rullgård -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+ -+/** -+ * @file -+ * @brief Vividas VIV (.viv) file demuxer -+ * @author Andrzej Szombierski [qq at kuku eu org] (2010-07) -+ * @sa http://wiki.multimedia.cx/index.php?title=Vividas_VIV -+ */ -+ -+#define AV_PKT_FLAG_KEY 0x0001 -+ -+#include "libavutil/intreadwrite.h" -+#include "avio_internal.h" -+#include "avformat.h" -+ -+#define MAX_AUDIO_SUBPACKETS 100 -+#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO -+#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO -+ -+typedef struct VIV_SB_block { -+ int size, n_packets; -+ int64_t byte_offset; -+ int packet_offset; -+} VIV_SB_block; -+ -+typedef struct VIV_SB_entry { -+ int size, flag; -+} VIV_SB_entry; -+ -+typedef struct VIV_AudioSubpacket { -+ int start, pcm_bytes; -+} VIV_AudioSubpacket; -+ -+typedef struct VIV_DemuxContext -+{ -+ int n_sb_blocks; -+ VIV_SB_block *sb_blocks; -+ -+ uint32_t sb_key; -+ int64_t sb_offset; -+ -+ int current_sb, current_sb_entry; -+ uint8_t *sb_buf; -+ AVIOContext *sb_pb; -+ int n_sb_entries; -+ VIV_SB_entry *sb_entries; -+ -+ int n_audio_subpackets; -+ int current_audio_subpacket; -+ -+ int audio_sample; -+ -+ VIV_AudioSubpacket audio_subpackets[MAX_AUDIO_SUBPACKETS]; -+} VIV_DemuxContext; -+ -+static int viv_probe(AVProbeData *p) -+{ -+ if(strncmp((char*)p->buf, "vividas03", 9)) -+ return 0; -+ -+ return AVPROBE_SCORE_MAX; -+} -+ -+const unsigned short keybits[32] = { -+ 163, 416, 893, 82, 223, 572, 1137, 430, -+ 659, 1104, 13, 626, 695, 972, 1465, 686, -+ 843, 1216, 317, 1122, 1383, 92, 513, 1158, -+ 1243, 48, 573, 1306, 1495, 396, 1009, 350, -+}; -+ -+static uint32_t decode_key(uint8_t *buf) -+{ -+ uint32_t key = 0; -+ int i; -+ -+ for (i = 0; i < 32; i++) { -+ unsigned p = keybits[i]; -+ key |= !!(buf[p>>3] & (1<<(p&7))) << i; -+ } -+ -+ return key; -+} -+ -+static void put_v(uint8_t *p, int v) -+{ -+ if(v>>28) -+ *p++ = ((v>>28)&0x7f)|0x80; -+ if(v>>21) -+ *p++ = ((v>>21)&0x7f)|0x80; -+ if(v>>14) -+ *p++ = ((v>>14)&0x7f)|0x80; -+ if(v>>7) -+ *p++ = ((v>>7)&0x7f)|0x80; -+ *p++ = v&0x7f; -+} -+ -+static unsigned int recover_key(unsigned char sample[4], int expected_size) -+{ -+ unsigned char plaintext[8] = { 'S', 'B' }; -+ put_v(plaintext+2, expected_size); -+ -+ return (sample[0]^plaintext[0])| -+ ((sample[1]^plaintext[1])<<8)| -+ ((sample[2]^plaintext[2])<<16)| -+ ((sample[3]^plaintext[3])<<24); -+} -+ -+static void xor_block(void *p1, void *p2, int size, int key, int *key_ptr) -+{ -+ int *d1 = p1; -+ int *d2 = p2; -+ int k = *key_ptr; -+ -+ size >>= 2; -+ -+ while (size--) { -+ *d2 = *d1 ^ k; -+ k += key; -+ d1++; -+ d2++; -+ } -+ -+ *key_ptr = k; -+} -+ -+static void decode_block(uint8_t *src, uint8_t *dest, int size, -+ uint32_t key, uint32_t *key_ptr, -+ int align) -+{ -+ int s = size; -+ char tmp[4]; -+ int a2; -+ -+ if (!size) -+ return; -+ -+ align &= 3; -+ a2 = (4 - align) & 3; -+ -+ if (align) { -+ uint32_t tmpkey = *key_ptr - key; -+ memcpy(tmp + align, src, a2); -+ xor_block(tmp, tmp, 4, key, &tmpkey); -+ memcpy(dest, tmp + align, a2); -+ s -= a2; -+ } -+ -+ if (s >= 4) { -+ if (!align) -+ align = 4; -+ xor_block(src + a2, dest + a2, s & ~3, -+ key, key_ptr); -+ s &= 3; -+ } -+ -+ if (s) { -+ size -= s; -+ memcpy(tmp, src + size, s); -+ xor_block(&tmp, &tmp, 4, key, key_ptr); -+ memcpy(dest + size, tmp, s); -+ } -+} -+ -+static uint32_t get_v(uint8_t *p) -+{ -+ uint32_t v = 0; -+ -+ do { -+ v <<= 7; -+ v += *p & 0x7f; -+ } while (*p++ & 0x80); -+ -+ return v; -+} -+ -+static uint8_t *read_vblock(AVIOContext *src, uint32_t *size, uint32_t key, uint32_t *k2, int align) -+{ -+ uint8_t tmp[4]; -+ uint8_t *buf; -+ unsigned n; -+ -+ if(avio_read(src, tmp, 4) != 4) -+ return NULL; -+ -+ decode_block(tmp, tmp, 4, key, k2, align); -+ -+ n = get_v(tmp); -+ -+ buf = av_malloc(n); -+ if (!buf) -+ return NULL; -+ -+ *size = n; -+ n -= 4; -+ -+ memcpy(buf, tmp, 4); -+ -+ if (avio_read(src, buf + 4, n) == n) { -+ decode_block(buf + 4, buf + 4, n, key, k2, align + 4); -+ } else { -+ av_free(buf); -+ buf = NULL; -+ } -+ -+ return buf; -+} -+ -+static uint8_t *read_sb_block(AVIOContext *src, unsigned *size, uint32_t *key, int expected_size) -+{ -+ uint8_t *buf; -+ uint8_t ibuf[8], sbuf[8]; -+ uint32_t k2; -+ int n; -+ -+ if (avio_read(src, ibuf, 8) < 8) -+ return NULL; -+ -+ k2 = *key; -+ decode_block(ibuf, sbuf, 8, *key, &k2, 0); -+ -+ n = get_v(sbuf+2); -+ -+ if (sbuf[0] != 'S' || sbuf[1] != 'B' || (expected_size>0 && n != expected_size)) { -+ uint32_t tmpkey = recover_key(ibuf, expected_size); -+ k2 = tmpkey; -+ decode_block(ibuf, sbuf, 8, tmpkey, &k2, 0); -+ n = get_v(sbuf+2); -+ if(sbuf[0] != 'S' || sbuf[1] != 'B' || expected_size != n) -+ return NULL; -+ *key = tmpkey; -+ } -+ -+ buf = av_malloc(n); -+ if (!buf) -+ return NULL; -+ -+ memcpy(buf, sbuf, 8); -+ -+ *size = n; -+ n -= 8; -+ -+ if (avio_read(src, buf+8, n) < n) { -+ av_free(buf); -+ return NULL; -+ } -+ -+ decode_block(buf + 8, buf + 8, n, *key, &k2, 0); -+ -+ return buf; -+} -+ -+static void track_header(VIV_DemuxContext *viv, AVFormatContext *s, uint8_t *buf, int size) -+{ -+ int i,j; -+ int64_t off; -+ int val_1; -+ int num_video, num_audio; -+ AVIOContext *pb=0; -+ -+ pb = avio_alloc_context(buf, size, 0, NULL, NULL, NULL, NULL); -+ //ff_get_v(pb); // track_header_len -+ ffio_read_varlen(pb); // track_header_len -+ avio_r8(pb); // '1' -+ -+ //val_1 = ff_get_v(pb); -+ val_1 = ffio_read_varlen(pb); -+ -+ for(i=0;icodec; -+ -+ st->id = i; -+ -+ vcodec->codec_type = CODEC_TYPE_VIDEO; -+ vcodec->codec_id = CODEC_ID_VP6; -+ -+ off = avio_tell(pb); -+ //off += ff_get_v(pb); -+ off += ffio_read_varlen(pb); -+ avio_r8(pb); // '3' -+ avio_r8(pb); // val_7 -+ st->time_base.num = avio_rl32(pb); // frame_time -+ st->time_base.den = avio_rl32(pb); // time_base -+ st->nb_frames = avio_rl32(pb); // n frames -+ vcodec->width = avio_rl16(pb); // width -+ vcodec->height = avio_rl16(pb); // height -+ avio_r8(pb); // val_8 -+ avio_rl32(pb); // val_9 -+ -+ vcodec->flags |= CODEC_FLAG_GLOBAL_HEADER; // ? -+ -+ avio_seek(pb, off, SEEK_SET); -+ } -+ -+ off = avio_tell(pb); -+ //off += ff_get_v(pb); // val_10 -+ off += ffio_read_varlen(pb); // val_10 -+ avio_r8(pb); // '4' -+ num_audio = avio_r8(pb); -+ avio_seek(pb, off, SEEK_SET); -+ -+ if(num_audio != 1) -+ av_log(s, AV_LOG_WARNING, "viv: number of audio tracks %d is not 1\n", num_audio); -+ -+ for(i=0;icodec; -+ -+ st->id = num_video + i; -+ -+ acodec->codec_type = CODEC_TYPE_AUDIO; -+ acodec->codec_id = CODEC_ID_VORBIS; -+ acodec->flags |= CODEC_FLAG_GLOBAL_HEADER; // ? -+ -+ off = avio_tell(pb); -+ //off += ff_get_v(pb); // length -+ off += ffio_read_varlen(pb); // length -+ avio_r8(pb); // '5' -+ avio_r8(pb); //codec_id -+ avio_rl16(pb); //codec_subid -+ acodec->channels = avio_rl16(pb); // channels -+ acodec->sample_rate = avio_rl32(pb); // sample_rate -+ avio_seek(pb, 10, SEEK_CUR); // data_1 -+ q = avio_r8(pb); -+ avio_seek(pb, q, SEEK_CUR); // data_2 -+ avio_r8(pb); // zeropad -+ -+ if(avio_tell(pb) < off) { -+ int num_data; -+ int xd_size = 0; -+ int data_len[256]; -+ uint8_t * p; -+ int offset = 1; -+ //ff_get_v(pb); // val_13 -+ ffio_read_varlen(pb); // val_13 -+ avio_r8(pb); // '19' -+ //ff_get_v(pb); // len_3 -+ ffio_read_varlen(pb); // len_3 -+ num_data = avio_r8(pb); -+ for(j=0;jextradata_size = 64 + xd_size + xd_size / 255; -+ acodec->extradata = (uint8_t*)av_mallocz(acodec->extradata_size); -+ -+ p = acodec->extradata; -+ p[0] = 2; -+ -+ for(j=0;jextradata_size = offset; -+ } -+ } -+ -+ av_free(pb); -+} -+ -+static void track_index(VIV_DemuxContext *viv, AVFormatContext *s, uint8_t *buf, int size) -+{ -+ int i; -+ int64_t off; -+ int poff; -+ int maxnp=0; -+ AVIOContext *pb=0; -+ -+ pb = avio_alloc_context(buf, size, 0, NULL, NULL, NULL, NULL); -+ //ff_get_v(pb); // track_index_len -+ ffio_read_varlen(pb); // track_index_len -+ avio_r8(pb); // 'c' -+ //viv->n_sb_blocks = ff_get_v(pb); -+ viv->n_sb_blocks = ffio_read_varlen(pb); -+ viv->sb_blocks = av_mallocz(sizeof(VIV_SB_block) * viv->n_sb_blocks); -+ if(!viv->sb_blocks) { -+ viv->n_sb_blocks = 0; -+ av_free(pb); -+ return; -+ } -+ -+ off = 0; -+ poff = 0; -+ -+ for(i=0;in_sb_blocks;i++) { -+ viv->sb_blocks[i].byte_offset = off; -+ viv->sb_blocks[i].packet_offset = poff; -+ -+ //viv->sb_blocks[i].size = ff_get_v(pb); -+ //viv->sb_blocks[i].n_packets = ff_get_v(pb); -+ viv->sb_blocks[i].size = ffio_read_varlen(pb); -+ viv->sb_blocks[i].n_packets = ffio_read_varlen(pb); -+ -+ off += viv->sb_blocks[i].size; -+ poff += viv->sb_blocks[i].n_packets; -+ -+ -+ if(maxnp < viv->sb_blocks[i].n_packets) -+ maxnp = viv->sb_blocks[i].n_packets; -+ } -+ -+ viv->sb_entries = av_mallocz(maxnp * sizeof(VIV_SB_entry)); -+ av_free(pb); -+} -+ -+static void load_sb_block(AVFormatContext *s, VIV_DemuxContext *viv, int expected_size) -+{ -+ uint32_t size=0; -+ int i; -+ AVIOContext *pb = 0; -+ if(viv->sb_pb) { -+ av_free(viv->sb_pb); -+ viv->sb_pb = NULL; -+ } -+ -+ if(viv->sb_buf) -+ av_free(viv->sb_buf); -+ -+ viv->sb_buf = read_sb_block(s->pb, &size, &viv->sb_key, expected_size); -+ if(!viv->sb_buf) { -+ return; -+ } -+ -+ pb = avio_alloc_context(viv->sb_buf, size, 0, NULL, NULL, NULL, NULL); -+ viv->sb_pb = pb; -+ -+ avio_r8(pb); // 'S' -+ avio_r8(pb); // 'B' -+ //ff_get_v(pb); // size -+ ffio_read_varlen(pb); // size -+ avio_r8(pb); // junk -+ //ff_get_v(pb); // first packet -+ ffio_read_varlen(pb); // first packet -+ -+ viv->n_sb_entries = viv->sb_blocks[viv->current_sb].n_packets; -+ -+ for(i=0;in_sb_entries;i++) { -+ //viv->sb_entries[i].size = ff_get_v(pb); -+ viv->sb_entries[i].size = ffio_read_varlen(pb); -+ viv->sb_entries[i].flag = avio_r8(pb); -+ } -+ -+ //ff_get_v(pb); // 0 -+ ffio_read_varlen(pb); // 0 -+ avio_r8(pb); // 0 -+ -+ viv->current_sb_entry = 0; -+} -+ -+static int viv_read_header(AVFormatContext *s, -+ AVFormatParameters *ap) -+{ -+ VIV_DemuxContext *viv = s->priv_data; -+ AVIOContext *pb = s->pb; -+ int64_t header_end; -+ int num_tracks; -+ uint32_t key, k2; -+ uint32_t v; -+ uint8_t keybuffer[187]; -+ uint32_t b22_size = 0; -+ uint32_t b22_key = 0; -+ uint8_t *buf = 0; -+ -+ // string "vividas03" -+ avio_seek(pb, 9, SEEK_CUR); -+ -+ header_end = avio_tell(pb); -+ -+ // v: header size -+ //header_end += ff_get_v(pb); -+ header_end += ffio_read_varlen(pb); -+ -+ // u8: n tracks -+ num_tracks = avio_r8(pb); -+ -+ if(num_tracks != 1) { -+ av_log(s, AV_LOG_ERROR, "number of tracks %d is not 1\n", num_tracks); -+ return AVERROR(EINVAL); -+ } -+ -+ v = avio_r8(pb); -+ avio_seek(pb, v, SEEK_CUR); -+ -+ avio_read(pb, keybuffer, 187); -+ key = decode_key(keybuffer); -+ viv->sb_key = key; -+ -+ avio_rl32(pb); // track_header_len -+ -+ for(;;) { -+ int64_t here = avio_tell(pb); -+ int block_len, block_type; -+ -+ if(here >= header_end) -+ break; -+ -+ //block_len = ff_get_v(pb); -+ block_len = ffio_read_varlen(pb); -+ block_type = avio_r8(pb); -+ -+ if(block_type == 22) { -+ avio_read(pb, keybuffer, 187); -+ b22_key = decode_key(keybuffer); -+ b22_size = avio_rl32(pb); -+ } -+ -+ avio_seek(pb, here + block_len, SEEK_SET); -+ } -+ -+ if(b22_size) { -+ k2 = b22_key; -+ buf = read_vblock(pb, &v, b22_key, &k2, 0); -+ if(!buf) -+ return AVERROR(EIO); -+ -+ av_free(buf); -+ } -+ -+ k2 = key; -+ buf = read_vblock(pb, &v, key, &k2, 0); -+ if(!buf) -+ return AVERROR(EIO); -+ track_header(viv, s, buf, v); -+ av_free(buf); -+ -+ buf = read_vblock(pb, &v, key, &k2, v); -+ if(!buf) -+ return AVERROR(EIO); -+ track_index(viv, s, buf, v); -+ av_free(buf); -+ -+ viv->sb_offset = avio_tell(pb); -+ if(viv->n_sb_blocks > 0) { -+ viv->current_sb = 0; -+ load_sb_block(s, viv, viv->sb_blocks[0].size); -+ } else { -+ viv->current_sb = -1; -+ } -+ -+ return 0; -+} -+ -+static int viv_read_packet(AVFormatContext *s, -+ AVPacket *pkt) -+{ -+ VIV_DemuxContext *viv = s->priv_data; -+ AVIOContext *pb; -+ int64_t off; -+ -+ if(viv->current_audio_subpacket < viv->n_audio_subpackets) { -+ // audio packets -+ AVStream *astream; -+ int size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - viv->audio_subpackets[viv->current_audio_subpacket].start; -+ pb = viv->sb_pb; -+ av_get_packet(pb, pkt, size); -+ pkt->pos += viv->sb_offset + viv->sb_blocks[viv->current_sb].byte_offset; -+ -+ pkt->stream_index = 1; -+ astream = s->streams[pkt->stream_index]; -+ -+ pkt->pts = viv->audio_sample * (long long)astream->time_base.den / (long long)astream->time_base.num / (long long)astream->codec->sample_rate; -+ viv->audio_sample += viv->audio_subpackets[viv->current_audio_subpacket].pcm_bytes / 2 / astream->codec->channels; -+ pkt->flags |= AV_PKT_FLAG_KEY; -+ viv->current_audio_subpacket++; -+ return 0; -+ } -+ -+ if(viv->current_sb_entry >= viv->n_sb_entries) { -+ if(viv->current_sb+1 >= viv->n_sb_blocks) -+ return AVERROR(EIO); -+ viv->current_sb++; -+ -+ load_sb_block(s, viv, 0); -+ viv->current_sb_entry = 0; -+ } -+ -+ pb = viv->sb_pb; -+ off = avio_tell(pb); -+ off += viv->sb_entries[viv->current_sb_entry].size; -+ -+ if(viv->sb_entries[viv->current_sb_entry].flag == 0) { -+ // A/V packet -+ int i; -+ //int v_size = ff_get_v(pb); -+ int v_size = ffio_read_varlen(pb); -+ ///*int a_size = */ff_get_v(pb); -+ /*int a_size = */ffio_read_varlen(pb); -+ av_get_packet(pb, pkt, v_size); -+ pkt->pos += viv->sb_offset + viv->sb_blocks[viv->current_sb].byte_offset; -+ -+ pkt->pts = viv->sb_blocks[viv->current_sb].packet_offset + viv->current_sb_entry; -+ pkt->flags |= (pkt->data[0]&0x80)?0:AV_PKT_FLAG_KEY; -+ pkt->stream_index = 0; -+ -+ for(i=0;i 0 && start == 0) -+ break; -+ -+ viv->n_audio_subpackets = i+1; -+ viv->audio_subpackets[i].start = start; -+ viv->audio_subpackets[i].pcm_bytes = pcm_bytes; -+ } -+ viv->audio_subpackets[viv->n_audio_subpackets].start = (int)(off - avio_tell(pb)); -+ viv->current_audio_subpacket = 0; -+ //viv->n_audio_subpackets = 0; -+ //avio_seek(pb, off, SEEK_SET); -+ -+ } else { -+ // V packet -+ //int v_size = ff_get_v(pb); -+ int v_size = ffio_read_varlen(pb); -+ av_get_packet(pb, pkt, v_size); -+ pkt->pos += viv->sb_offset + viv->sb_blocks[viv->current_sb].byte_offset; -+ pkt->pts = viv->sb_blocks[viv->current_sb].packet_offset + viv->current_sb_entry; -+ pkt->flags |= (pkt->data[0]&0x80)?0:AV_PKT_FLAG_KEY; -+ pkt->stream_index = 0; -+ } -+ -+ viv->current_sb_entry++; -+ -+// avio_seek(pb, off, SEEK_SET); -+ -+ return 0; -+} -+ -+static int viv_read_close(AVFormatContext *s) -+{ -+ VIV_DemuxContext *viv = s->priv_data; -+ if(viv->sb_pb) -+ av_free(viv->sb_pb); -+ -+ if(viv->sb_buf) -+ av_free(viv->sb_buf); -+ -+ if(viv->sb_blocks) -+ av_free(viv->sb_blocks); -+ -+ if(viv->sb_entries) -+ av_free(viv->sb_entries); -+ -+ return 0; -+} -+ -+static int viv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) -+{ -+ VIV_DemuxContext *viv = s->priv_data; -+ int frame = 0; -+ int i; -+ -+ if(stream_index == 0) -+ frame = (int)timestamp; -+ else -+ frame = (int)timestamp * s->streams[stream_index]->time_base.den * s->streams[0]->time_base.num / s->streams[stream_index]->time_base.num / s->streams[0]->time_base.den; -+ -+ for(i=0;in_sb_blocks;i++) { -+ if(frame >= viv->sb_blocks[i].packet_offset && frame < viv->sb_blocks[i].packet_offset + viv->sb_blocks[i].n_packets) { -+ // flush audio packet queue -+ viv->current_audio_subpacket = 0; -+ viv->n_audio_subpackets = 0; -+ viv->current_sb = i; -+ // seek to ith sb block -+ avio_seek(s->pb, viv->sb_offset + viv->sb_blocks[i].byte_offset, SEEK_SET); -+ // load the block -+ load_sb_block(s, viv, 0); -+ // most problematic part: guess audio offset -+ viv->audio_sample = (int64_t)viv->sb_blocks[i].packet_offset * (int64_t)s->streams[1]->codec->sample_rate * s->streams[0]->time_base.num / s->streams[0]->time_base.den; -+ // hand-tuned 1.3s a/v offset -+ viv->audio_sample += 1300 * s->streams[1]->codec->sample_rate / 1000; -+ viv->current_sb_entry = 0; -+ return 1; -+ } -+ } -+ return 0; -+} -+ -+AVInputFormat ff_vividas_demuxer = { -+ "vividas", -+ "Vividas VIV format", -+ sizeof(VIV_DemuxContext), -+ viv_probe, -+ viv_read_header, -+ viv_read_packet, -+ viv_read_close, -+ viv_read_seek -+}; -+ -diff --git a/patches/0110-vividas-support.patch b/patches/0110-vividas-support.patch -new file mode 100644 -index 0000000..713a0a5 ---- /dev/null -+++ b/patches/0110-vividas-support.patch -@@ -0,0 +1,770 @@ -+diff --git a/lib/ffmpeg/libavformat/Makefile b/lib/ffmpeg/libavformat/Makefile -+index bd2b17b..6642498 100644 -+--- a/lib/ffmpeg/libavformat/Makefile -++++ b/lib/ffmpeg/libavformat/Makefile -+@@ -315,6 +315,7 @@ OBJS-$(CONFIG_TXD_DEMUXER) += txd.o -+ OBJS-$(CONFIG_VC1_DEMUXER) += rawdec.o -+ OBJS-$(CONFIG_VC1T_DEMUXER) += vc1test.o -+ OBJS-$(CONFIG_VC1T_MUXER) += vc1testenc.o -++OBJS-$(CONFIG_VIVIDAS_DEMUXER) += vividas.o -+ OBJS-$(CONFIG_VMD_DEMUXER) += sierravmd.o -+ OBJS-$(CONFIG_VOC_DEMUXER) += vocdec.o voc.o -+ OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o -+diff --git a/lib/ffmpeg/libavformat/allformats.c b/lib/ffmpeg/libavformat/allformats.c -+index 134839f..0af5ba9 100644 -+--- a/lib/ffmpeg/libavformat/allformats.c -++++ b/lib/ffmpeg/libavformat/allformats.c -+@@ -232,6 +232,7 @@ void av_register_all(void) -+ REGISTER_DEMUXER (TTY, tty); -+ REGISTER_DEMUXER (VC1, vc1); -+ REGISTER_MUXDEMUX (VC1T, vc1t); -++ REGISTER_DEMUXER (VIVIDAS, vividas); -+ REGISTER_DEMUXER (VMD, vmd); -+ REGISTER_MUXDEMUX (VOC, voc); -+ REGISTER_DEMUXER (VQF, vqf); -+diff --git a/lib/ffmpeg/libavformat/vividas.c b/lib/ffmpeg/libavformat/vividas.c -+new file mode 100644 -+index 0000000..2d3ba27 -+--- /dev/null -++++ b/lib/ffmpeg/libavformat/vividas.c -+@@ -0,0 +1,740 @@ -++/* -++ * Vividas VIV format Demuxer -++ * Copyright (c) 2010 Andrzej Szombierski -++ * based on vivparse Copyright (c) 2007 Måns Rullgård -++ * -++ * This file is part of FFmpeg. -++ * -++ * FFmpeg is free software; you can redistribute it and/or -++ * modify it under the terms of the GNU Lesser General Public -++ * License as published by the Free Software Foundation; either -++ * version 2.1 of the License, or (at your option) any later version. -++ * -++ * FFmpeg is distributed in the hope that it will be useful, -++ * but WITHOUT ANY WARRANTY; without even the implied warranty of -++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -++ * Lesser General Public License for more details. -++ * -++ * You should have received a copy of the GNU Lesser General Public -++ * License along with FFmpeg; if not, write to the Free Software -++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -++ */ -++ -++/** -++ * @file -++ * @brief Vividas VIV (.viv) file demuxer -++ * @author Andrzej Szombierski [qq at kuku eu org] (2010-07) -++ * @sa http://wiki.multimedia.cx/index.php?title=Vividas_VIV -++ */ -++ -++#define AV_PKT_FLAG_KEY 0x0001 -++ -++#include "libavutil/intreadwrite.h" -++#include "avio_internal.h" -++#include "avformat.h" -++ -++#define MAX_AUDIO_SUBPACKETS 100 -++#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO -++#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO -++ -++typedef struct VIV_SB_block { -++ int size, n_packets; -++ int64_t byte_offset; -++ int packet_offset; -++} VIV_SB_block; -++ -++typedef struct VIV_SB_entry { -++ int size, flag; -++} VIV_SB_entry; -++ -++typedef struct VIV_AudioSubpacket { -++ int start, pcm_bytes; -++} VIV_AudioSubpacket; -++ -++typedef struct VIV_DemuxContext -++{ -++ int n_sb_blocks; -++ VIV_SB_block *sb_blocks; -++ -++ uint32_t sb_key; -++ int64_t sb_offset; -++ -++ int current_sb, current_sb_entry; -++ uint8_t *sb_buf; -++ AVIOContext *sb_pb; -++ int n_sb_entries; -++ VIV_SB_entry *sb_entries; -++ -++ int n_audio_subpackets; -++ int current_audio_subpacket; -++ -++ int audio_sample; -++ -++ VIV_AudioSubpacket audio_subpackets[MAX_AUDIO_SUBPACKETS]; -++} VIV_DemuxContext; -++ -++static int viv_probe(AVProbeData *p) -++{ -++ if(strncmp((char*)p->buf, "vividas03", 9)) -++ return 0; -++ -++ return AVPROBE_SCORE_MAX; -++} -++ -++const unsigned short keybits[32] = { -++ 163, 416, 893, 82, 223, 572, 1137, 430, -++ 659, 1104, 13, 626, 695, 972, 1465, 686, -++ 843, 1216, 317, 1122, 1383, 92, 513, 1158, -++ 1243, 48, 573, 1306, 1495, 396, 1009, 350, -++}; -++ -++static uint32_t decode_key(uint8_t *buf) -++{ -++ uint32_t key = 0; -++ int i; -++ -++ for (i = 0; i < 32; i++) { -++ unsigned p = keybits[i]; -++ key |= !!(buf[p>>3] & (1<<(p&7))) << i; -++ } -++ -++ return key; -++} -++ -++static void put_v(uint8_t *p, int v) -++{ -++ if(v>>28) -++ *p++ = ((v>>28)&0x7f)|0x80; -++ if(v>>21) -++ *p++ = ((v>>21)&0x7f)|0x80; -++ if(v>>14) -++ *p++ = ((v>>14)&0x7f)|0x80; -++ if(v>>7) -++ *p++ = ((v>>7)&0x7f)|0x80; -++ *p++ = v&0x7f; -++} -++ -++static unsigned int recover_key(unsigned char sample[4], int expected_size) -++{ -++ unsigned char plaintext[8] = { 'S', 'B' }; -++ put_v(plaintext+2, expected_size); -++ -++ return (sample[0]^plaintext[0])| -++ ((sample[1]^plaintext[1])<<8)| -++ ((sample[2]^plaintext[2])<<16)| -++ ((sample[3]^plaintext[3])<<24); -++} -++ -++static void xor_block(void *p1, void *p2, int size, int key, int *key_ptr) -++{ -++ int *d1 = p1; -++ int *d2 = p2; -++ int k = *key_ptr; -++ -++ size >>= 2; -++ -++ while (size--) { -++ *d2 = *d1 ^ k; -++ k += key; -++ d1++; -++ d2++; -++ } -++ -++ *key_ptr = k; -++} -++ -++static void decode_block(uint8_t *src, uint8_t *dest, int size, -++ uint32_t key, uint32_t *key_ptr, -++ int align) -++{ -++ int s = size; -++ char tmp[4]; -++ int a2; -++ -++ if (!size) -++ return; -++ -++ align &= 3; -++ a2 = (4 - align) & 3; -++ -++ if (align) { -++ uint32_t tmpkey = *key_ptr - key; -++ memcpy(tmp + align, src, a2); -++ xor_block(tmp, tmp, 4, key, &tmpkey); -++ memcpy(dest, tmp + align, a2); -++ s -= a2; -++ } -++ -++ if (s >= 4) { -++ if (!align) -++ align = 4; -++ xor_block(src + a2, dest + a2, s & ~3, -++ key, key_ptr); -++ s &= 3; -++ } -++ -++ if (s) { -++ size -= s; -++ memcpy(tmp, src + size, s); -++ xor_block(&tmp, &tmp, 4, key, key_ptr); -++ memcpy(dest + size, tmp, s); -++ } -++} -++ -++static uint32_t get_v(uint8_t *p) -++{ -++ uint32_t v = 0; -++ -++ do { -++ v <<= 7; -++ v += *p & 0x7f; -++ } while (*p++ & 0x80); -++ -++ return v; -++} -++ -++static uint8_t *read_vblock(AVIOContext *src, uint32_t *size, uint32_t key, uint32_t *k2, int align) -++{ -++ uint8_t tmp[4]; -++ uint8_t *buf; -++ unsigned n; -++ -++ if(avio_read(src, tmp, 4) != 4) -++ return NULL; -++ -++ decode_block(tmp, tmp, 4, key, k2, align); -++ -++ n = get_v(tmp); -++ -++ buf = av_malloc(n); -++ if (!buf) -++ return NULL; -++ -++ *size = n; -++ n -= 4; -++ -++ memcpy(buf, tmp, 4); -++ -++ if (avio_read(src, buf + 4, n) == n) { -++ decode_block(buf + 4, buf + 4, n, key, k2, align + 4); -++ } else { -++ av_free(buf); -++ buf = NULL; -++ } -++ -++ return buf; -++} -++ -++static uint8_t *read_sb_block(AVIOContext *src, unsigned *size, uint32_t *key, int expected_size) -++{ -++ uint8_t *buf; -++ uint8_t ibuf[8], sbuf[8]; -++ uint32_t k2; -++ int n; -++ -++ if (avio_read(src, ibuf, 8) < 8) -++ return NULL; -++ -++ k2 = *key; -++ decode_block(ibuf, sbuf, 8, *key, &k2, 0); -++ -++ n = get_v(sbuf+2); -++ -++ if (sbuf[0] != 'S' || sbuf[1] != 'B' || (expected_size>0 && n != expected_size)) { -++ uint32_t tmpkey = recover_key(ibuf, expected_size); -++ k2 = tmpkey; -++ decode_block(ibuf, sbuf, 8, tmpkey, &k2, 0); -++ n = get_v(sbuf+2); -++ if(sbuf[0] != 'S' || sbuf[1] != 'B' || expected_size != n) -++ return NULL; -++ *key = tmpkey; -++ } -++ -++ buf = av_malloc(n); -++ if (!buf) -++ return NULL; -++ -++ memcpy(buf, sbuf, 8); -++ -++ *size = n; -++ n -= 8; -++ -++ if (avio_read(src, buf+8, n) < n) { -++ av_free(buf); -++ return NULL; -++ } -++ -++ decode_block(buf + 8, buf + 8, n, *key, &k2, 0); -++ -++ return buf; -++} -++ -++static void track_header(VIV_DemuxContext *viv, AVFormatContext *s, uint8_t *buf, int size) -++{ -++ int i,j; -++ int64_t off; -++ int val_1; -++ int num_video, num_audio; -++ AVIOContext *pb=0; -++ -++ pb = avio_alloc_context(buf, size, 0, NULL, NULL, NULL, NULL); -++ //ff_get_v(pb); // track_header_len -++ ffio_read_varlen(pb); // track_header_len -++ avio_r8(pb); // '1' -++ -++ //val_1 = ff_get_v(pb); -++ val_1 = ffio_read_varlen(pb); -++ -++ for(i=0;icodec; -++ -++ st->id = i; -++ -++ vcodec->codec_type = CODEC_TYPE_VIDEO; -++ vcodec->codec_id = CODEC_ID_VP6; -++ -++ off = avio_tell(pb); -++ //off += ff_get_v(pb); -++ off += ffio_read_varlen(pb); -++ avio_r8(pb); // '3' -++ avio_r8(pb); // val_7 -++ st->time_base.num = avio_rl32(pb); // frame_time -++ st->time_base.den = avio_rl32(pb); // time_base -++ st->nb_frames = avio_rl32(pb); // n frames -++ vcodec->width = avio_rl16(pb); // width -++ vcodec->height = avio_rl16(pb); // height -++ avio_r8(pb); // val_8 -++ avio_rl32(pb); // val_9 -++ -++ vcodec->flags |= CODEC_FLAG_GLOBAL_HEADER; // ? -++ -++ avio_seek(pb, off, SEEK_SET); -++ } -++ -++ off = avio_tell(pb); -++ //off += ff_get_v(pb); // val_10 -++ off += ffio_read_varlen(pb); // val_10 -++ avio_r8(pb); // '4' -++ num_audio = avio_r8(pb); -++ avio_seek(pb, off, SEEK_SET); -++ -++ if(num_audio != 1) -++ av_log(s, AV_LOG_WARNING, "viv: number of audio tracks %d is not 1\n", num_audio); -++ -++ for(i=0;icodec; -++ -++ st->id = num_video + i; -++ -++ acodec->codec_type = CODEC_TYPE_AUDIO; -++ acodec->codec_id = CODEC_ID_VORBIS; -++ acodec->flags |= CODEC_FLAG_GLOBAL_HEADER; // ? -++ -++ off = avio_tell(pb); -++ //off += ff_get_v(pb); // length -++ off += ffio_read_varlen(pb); // length -++ avio_r8(pb); // '5' -++ avio_r8(pb); //codec_id -++ avio_rl16(pb); //codec_subid -++ acodec->channels = avio_rl16(pb); // channels -++ acodec->sample_rate = avio_rl32(pb); // sample_rate -++ avio_seek(pb, 10, SEEK_CUR); // data_1 -++ q = avio_r8(pb); -++ avio_seek(pb, q, SEEK_CUR); // data_2 -++ avio_r8(pb); // zeropad -++ -++ if(avio_tell(pb) < off) { -++ int num_data; -++ int xd_size = 0; -++ int data_len[256]; -++ uint8_t * p; -++ int offset = 1; -++ //ff_get_v(pb); // val_13 -++ ffio_read_varlen(pb); // val_13 -++ avio_r8(pb); // '19' -++ //ff_get_v(pb); // len_3 -++ ffio_read_varlen(pb); // len_3 -++ num_data = avio_r8(pb); -++ for(j=0;jextradata_size = 64 + xd_size + xd_size / 255; -++ acodec->extradata = (uint8_t*)av_mallocz(acodec->extradata_size); -++ -++ p = acodec->extradata; -++ p[0] = 2; -++ -++ for(j=0;jextradata_size = offset; -++ } -++ } -++ -++ av_free(pb); -++} -++ -++static void track_index(VIV_DemuxContext *viv, AVFormatContext *s, uint8_t *buf, int size) -++{ -++ int i; -++ int64_t off; -++ int poff; -++ int maxnp=0; -++ AVIOContext *pb=0; -++ -++ pb = avio_alloc_context(buf, size, 0, NULL, NULL, NULL, NULL); -++ //ff_get_v(pb); // track_index_len -++ ffio_read_varlen(pb); // track_index_len -++ avio_r8(pb); // 'c' -++ //viv->n_sb_blocks = ff_get_v(pb); -++ viv->n_sb_blocks = ffio_read_varlen(pb); -++ viv->sb_blocks = av_mallocz(sizeof(VIV_SB_block) * viv->n_sb_blocks); -++ if(!viv->sb_blocks) { -++ viv->n_sb_blocks = 0; -++ av_free(pb); -++ return; -++ } -++ -++ off = 0; -++ poff = 0; -++ -++ for(i=0;in_sb_blocks;i++) { -++ viv->sb_blocks[i].byte_offset = off; -++ viv->sb_blocks[i].packet_offset = poff; -++ -++ //viv->sb_blocks[i].size = ff_get_v(pb); -++ //viv->sb_blocks[i].n_packets = ff_get_v(pb); -++ viv->sb_blocks[i].size = ffio_read_varlen(pb); -++ viv->sb_blocks[i].n_packets = ffio_read_varlen(pb); -++ -++ off += viv->sb_blocks[i].size; -++ poff += viv->sb_blocks[i].n_packets; -++ -++ -++ if(maxnp < viv->sb_blocks[i].n_packets) -++ maxnp = viv->sb_blocks[i].n_packets; -++ } -++ -++ viv->sb_entries = av_mallocz(maxnp * sizeof(VIV_SB_entry)); -++ av_free(pb); -++} -++ -++static void load_sb_block(AVFormatContext *s, VIV_DemuxContext *viv, int expected_size) -++{ -++ uint32_t size=0; -++ int i; -++ AVIOContext *pb = 0; -++ if(viv->sb_pb) { -++ av_free(viv->sb_pb); -++ viv->sb_pb = NULL; -++ } -++ -++ if(viv->sb_buf) -++ av_free(viv->sb_buf); -++ -++ viv->sb_buf = read_sb_block(s->pb, &size, &viv->sb_key, expected_size); -++ if(!viv->sb_buf) { -++ return; -++ } -++ -++ pb = avio_alloc_context(viv->sb_buf, size, 0, NULL, NULL, NULL, NULL); -++ viv->sb_pb = pb; -++ -++ avio_r8(pb); // 'S' -++ avio_r8(pb); // 'B' -++ //ff_get_v(pb); // size -++ ffio_read_varlen(pb); // size -++ avio_r8(pb); // junk -++ //ff_get_v(pb); // first packet -++ ffio_read_varlen(pb); // first packet -++ -++ viv->n_sb_entries = viv->sb_blocks[viv->current_sb].n_packets; -++ -++ for(i=0;in_sb_entries;i++) { -++ //viv->sb_entries[i].size = ff_get_v(pb); -++ viv->sb_entries[i].size = ffio_read_varlen(pb); -++ viv->sb_entries[i].flag = avio_r8(pb); -++ } -++ -++ //ff_get_v(pb); // 0 -++ ffio_read_varlen(pb); // 0 -++ avio_r8(pb); // 0 -++ -++ viv->current_sb_entry = 0; -++} -++ -++static int viv_read_header(AVFormatContext *s, -++ AVFormatParameters *ap) -++{ -++ VIV_DemuxContext *viv = s->priv_data; -++ AVIOContext *pb = s->pb; -++ int64_t header_end; -++ int num_tracks; -++ uint32_t key, k2; -++ uint32_t v; -++ uint8_t keybuffer[187]; -++ uint32_t b22_size = 0; -++ uint32_t b22_key = 0; -++ uint8_t *buf = 0; -++ -++ // string "vividas03" -++ avio_seek(pb, 9, SEEK_CUR); -++ -++ header_end = avio_tell(pb); -++ -++ // v: header size -++ //header_end += ff_get_v(pb); -++ header_end += ffio_read_varlen(pb); -++ -++ // u8: n tracks -++ num_tracks = avio_r8(pb); -++ -++ if(num_tracks != 1) { -++ av_log(s, AV_LOG_ERROR, "number of tracks %d is not 1\n", num_tracks); -++ return AVERROR(EINVAL); -++ } -++ -++ v = avio_r8(pb); -++ avio_seek(pb, v, SEEK_CUR); -++ -++ avio_read(pb, keybuffer, 187); -++ key = decode_key(keybuffer); -++ viv->sb_key = key; -++ -++ avio_rl32(pb); // track_header_len -++ -++ for(;;) { -++ int64_t here = avio_tell(pb); -++ int block_len, block_type; -++ -++ if(here >= header_end) -++ break; -++ -++ //block_len = ff_get_v(pb); -++ block_len = ffio_read_varlen(pb); -++ block_type = avio_r8(pb); -++ -++ if(block_type == 22) { -++ avio_read(pb, keybuffer, 187); -++ b22_key = decode_key(keybuffer); -++ b22_size = avio_rl32(pb); -++ } -++ -++ avio_seek(pb, here + block_len, SEEK_SET); -++ } -++ -++ if(b22_size) { -++ k2 = b22_key; -++ buf = read_vblock(pb, &v, b22_key, &k2, 0); -++ if(!buf) -++ return AVERROR(EIO); -++ -++ av_free(buf); -++ } -++ -++ k2 = key; -++ buf = read_vblock(pb, &v, key, &k2, 0); -++ if(!buf) -++ return AVERROR(EIO); -++ track_header(viv, s, buf, v); -++ av_free(buf); -++ -++ buf = read_vblock(pb, &v, key, &k2, v); -++ if(!buf) -++ return AVERROR(EIO); -++ track_index(viv, s, buf, v); -++ av_free(buf); -++ -++ viv->sb_offset = avio_tell(pb); -++ if(viv->n_sb_blocks > 0) { -++ viv->current_sb = 0; -++ load_sb_block(s, viv, viv->sb_blocks[0].size); -++ } else { -++ viv->current_sb = -1; -++ } -++ -++ return 0; -++} -++ -++static int viv_read_packet(AVFormatContext *s, -++ AVPacket *pkt) -++{ -++ VIV_DemuxContext *viv = s->priv_data; -++ AVIOContext *pb; -++ int64_t off; -++ -++ if(viv->current_audio_subpacket < viv->n_audio_subpackets) { -++ // audio packets -++ AVStream *astream; -++ int size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - viv->audio_subpackets[viv->current_audio_subpacket].start; -++ pb = viv->sb_pb; -++ av_get_packet(pb, pkt, size); -++ pkt->pos += viv->sb_offset + viv->sb_blocks[viv->current_sb].byte_offset; -++ -++ pkt->stream_index = 1; -++ astream = s->streams[pkt->stream_index]; -++ -++ pkt->pts = viv->audio_sample * (long long)astream->time_base.den / (long long)astream->time_base.num / (long long)astream->codec->sample_rate; -++ viv->audio_sample += viv->audio_subpackets[viv->current_audio_subpacket].pcm_bytes / 2 / astream->codec->channels; -++ pkt->flags |= AV_PKT_FLAG_KEY; -++ viv->current_audio_subpacket++; -++ return 0; -++ } -++ -++ if(viv->current_sb_entry >= viv->n_sb_entries) { -++ if(viv->current_sb+1 >= viv->n_sb_blocks) -++ return AVERROR(EIO); -++ viv->current_sb++; -++ -++ load_sb_block(s, viv, 0); -++ viv->current_sb_entry = 0; -++ } -++ -++ pb = viv->sb_pb; -++ off = avio_tell(pb); -++ off += viv->sb_entries[viv->current_sb_entry].size; -++ -++ if(viv->sb_entries[viv->current_sb_entry].flag == 0) { -++ // A/V packet -++ int i; -++ //int v_size = ff_get_v(pb); -++ int v_size = ffio_read_varlen(pb); -++ ///*int a_size = */ff_get_v(pb); -++ /*int a_size = */ffio_read_varlen(pb); -++ av_get_packet(pb, pkt, v_size); -++ pkt->pos += viv->sb_offset + viv->sb_blocks[viv->current_sb].byte_offset; -++ -++ pkt->pts = viv->sb_blocks[viv->current_sb].packet_offset + viv->current_sb_entry; -++ pkt->flags |= (pkt->data[0]&0x80)?0:AV_PKT_FLAG_KEY; -++ pkt->stream_index = 0; -++ -++ for(i=0;i 0 && start == 0) -++ break; -++ -++ viv->n_audio_subpackets = i+1; -++ viv->audio_subpackets[i].start = start; -++ viv->audio_subpackets[i].pcm_bytes = pcm_bytes; -++ } -++ viv->audio_subpackets[viv->n_audio_subpackets].start = (int)(off - avio_tell(pb)); -++ viv->current_audio_subpacket = 0; -++ //viv->n_audio_subpackets = 0; -++ //avio_seek(pb, off, SEEK_SET); -++ -++ } else { -++ // V packet -++ //int v_size = ff_get_v(pb); -++ int v_size = ffio_read_varlen(pb); -++ av_get_packet(pb, pkt, v_size); -++ pkt->pos += viv->sb_offset + viv->sb_blocks[viv->current_sb].byte_offset; -++ pkt->pts = viv->sb_blocks[viv->current_sb].packet_offset + viv->current_sb_entry; -++ pkt->flags |= (pkt->data[0]&0x80)?0:AV_PKT_FLAG_KEY; -++ pkt->stream_index = 0; -++ } -++ -++ viv->current_sb_entry++; -++ -++// avio_seek(pb, off, SEEK_SET); -++ -++ return 0; -++} -++ -++static int viv_read_close(AVFormatContext *s) -++{ -++ VIV_DemuxContext *viv = s->priv_data; -++ if(viv->sb_pb) -++ av_free(viv->sb_pb); -++ -++ if(viv->sb_buf) -++ av_free(viv->sb_buf); -++ -++ if(viv->sb_blocks) -++ av_free(viv->sb_blocks); -++ -++ if(viv->sb_entries) -++ av_free(viv->sb_entries); -++ -++ return 0; -++} -++ -++static int viv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) -++{ -++ VIV_DemuxContext *viv = s->priv_data; -++ int frame = 0; -++ int i; -++ -++ if(stream_index == 0) -++ frame = (int)timestamp; -++ else -++ frame = (int)timestamp * s->streams[stream_index]->time_base.den * s->streams[0]->time_base.num / s->streams[stream_index]->time_base.num / s->streams[0]->time_base.den; -++ -++ for(i=0;in_sb_blocks;i++) { -++ if(frame >= viv->sb_blocks[i].packet_offset && frame < viv->sb_blocks[i].packet_offset + viv->sb_blocks[i].n_packets) { -++ // flush audio packet queue -++ viv->current_audio_subpacket = 0; -++ viv->n_audio_subpackets = 0; -++ viv->current_sb = i; -++ // seek to ith sb block -++ avio_seek(s->pb, viv->sb_offset + viv->sb_blocks[i].byte_offset, SEEK_SET); -++ // load the block -++ load_sb_block(s, viv, 0); -++ // most problematic part: guess audio offset -++ viv->audio_sample = (int64_t)viv->sb_blocks[i].packet_offset * (int64_t)s->streams[1]->codec->sample_rate * s->streams[0]->time_base.num / s->streams[0]->time_base.den; -++ // hand-tuned 1.3s a/v offset -++ viv->audio_sample += 1300 * s->streams[1]->codec->sample_rate / 1000; -++ viv->current_sb_entry = 0; -++ return 1; -++ } -++ } -++ return 0; -++} -++ -++AVInputFormat ff_vividas_demuxer = { -++ "vividas", -++ "Vividas VIV format", -++ sizeof(VIV_DemuxContext), -++ viv_probe, -++ viv_read_header, -++ viv_read_packet, -++ viv_read_close, -++ viv_read_seek -++}; -++ --- -1.7.9.5 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-913-h264-do_not_discard_NAL_SEI_when_skipping_frames.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-913-h264-do_not_discard_NAL_SEI_when_skipping_frames.patch deleted file mode 100644 index db07070c34..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-913-h264-do_not_discard_NAL_SEI_when_skipping_frames.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -Naur ffmpeg-0.10.7/libavcodec/h264.c ffmpeg-0.10.7.patch/libavcodec/h264.c ---- ffmpeg-0.10.7/libavcodec/h264.c 2013-04-10 03:52:33.000000000 +0200 -+++ ffmpeg-0.10.7.patch/libavcodec/h264.c 2013-09-09 17:25:55.377208927 +0200 -@@ -3962,8 +3962,7 @@ - continue; - } - -- //FIXME do not discard SEI id -- if(avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0) -+ if (avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0 && h->nal_unit_type != NAL_SEI) - continue; - - again: diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.01-h264_parser-Initialize_the_h264dsp_context_in_the_parser_as_well.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.01-h264_parser-Initialize_the_h264dsp_context_in_the_parser_as_well.patch deleted file mode 100644 index ce5891af17..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.01-h264_parser-Initialize_the_h264dsp_context_in_the_parser_as_well.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 90ac611930e202c8255887c6b3e82ff97a1117f0 Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Thu, 22 Aug 2013 14:34:37 +0100 -Subject: [PATCH] h264_parser: Initialize the h264dsp context in the parser as - well -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Each AVStream struct for an H.264 elementary stream actually has two -copies of the H264DSPContext struct (and in fact all the other members -of H264Context as well): - -((H264Context *) ((AVStream *)st)->codec->priv_data)->h264dsp -((H264Context *) ((AVStream *)st)->parser->priv_data)->h264dsp - -but only the first of these was actually being initialised. This -prevented the addition of platform-specific implementations of -parser-related functions. - -Signed-off-by: Martin Storsjö ---- - libavcodec/h264_parser.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c -index c9dea81..98e2844 100644 ---- a/libavcodec/h264_parser.c -+++ b/libavcodec/h264_parser.c -@@ -377,6 +377,7 @@ static int init(AVCodecParserContext *s) - H264Context *h = s->priv_data; - h->thread_context[0] = h; - h->s.slice_context_count = 1; -+ ff_h264dsp_init(&h->h264dsp, 8, 1); - return 0; - } - --- -1.8.1.6 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.02-h264dsp-Factorize_code_into_a_new_function-h264_find_start_code_canditate.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.02-h264dsp-Factorize_code_into_a_new_function-h264_find_start_code_canditate.patch deleted file mode 100644 index 21bb17d783..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.02-h264dsp-Factorize_code_into_a_new_function-h264_find_start_code_canditate.patch +++ /dev/null @@ -1,129 +0,0 @@ -From c58d69bea87c77c7a1e8221624137beaaa670586 Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Thu, 22 Aug 2013 14:37:18 +0100 -Subject: [PATCH] h264dsp: Factorize code into a new function, - h264_find_start_code_candidate -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This performs the start code search which was previously part of -h264_find_frame_end() - the most CPU intensive part of the function. - -By itself, this results in a performance regression: - Before After - Mean StdDev Mean StdDev Change -Overall time 2925.6 26.2 3068.5 31.7 -4.7% - -but this can more than be made up for by platform-optimised -implementations of the function. - -Signed-off-by: Martin Storsjö ---- - libavcodec/h264_parser.c | 21 +++------------------ - libavcodec/h264dsp.c | 29 +++++++++++++++++++++++++++++ - libavcodec/h264dsp.h | 9 +++++++++ - 3 files changed, 41 insertions(+), 18 deletions(-) - -diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c -index 98e2844..41c874d 100644 ---- a/libavcodec/h264_parser.c -+++ b/libavcodec/h264_parser.c -@@ -65,24 +65,9 @@ static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_si - } - - if(state==7){ --#if HAVE_FAST_UNALIGNED -- /* we check ih264dsp.h264_find_start_code_candidate(buf + i, buf_size - i); -+ if (i < buf_size) -+ state = 2; - }else if(state<=2){ - if(buf[i]==1) state^= 5; //2->7, 1->4, 0->5 - else if(buf[i]) state = 7; -diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c -index bd35aa3..0703172 100644 ---- a/libavcodec/h264dsp.c -+++ b/libavcodec/h264dsp.c -@@ -41,6 +41,34 @@ - #include "h264dsp_template.c" - #undef BIT_DEPTH - -+static int h264_find_start_code_candidate_c(const uint8_t *buf, int size) -+{ -+ int i = 0; -+#if HAVE_FAST_UNALIGNED -+ /* we check i < size instead of i + 3 / 7 because it is -+ * simpler and there must be FF_INPUT_BUFFER_PADDING_SIZE -+ * bytes at the end. -+ */ -+#if HAVE_FAST_64BIT -+ while (i < size && -+ !((~*(const uint64_t *)(buf + i) & -+ (*(const uint64_t *)(buf + i) - 0x0101010101010101ULL)) & -+ 0x8080808080808080ULL)) -+ i += 8; -+#else -+ while (i < size && -+ !((~*(const uint32_t *)(buf + i) & -+ (*(const uint32_t *)(buf + i) - 0x01010101U)) & -+ 0x80808080U)) -+ i += 4; -+#endif -+#endif -+ for (; i < size; i++) -+ if (!buf[i]) -+ break; -+ return i; -+} -+ - void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) - { - #undef FUNC -@@ -110,6 +138,7 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_fo - H264_DSP(8); - break; - } -+ c->h264_find_start_code_candidate = h264_find_start_code_candidate_c; - - if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc); - if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc); -diff --git a/libavcodec/h264dsp.h b/libavcodec/h264dsp.h -index 490a936..1d172f1 100644 ---- a/libavcodec/h264dsp.h -+++ b/libavcodec/h264dsp.h -@@ -74,6 +74,15 @@ typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int h - void (*h264_idct_add16intra)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[15*8]); - void (*h264_luma_dc_dequant_idct)(DCTELEM *output, DCTELEM *input/*align 16*/, int qmul); - void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul); -+ -+ /** -+ * Search buf from the start for up to size bytes. Return the index -+ * of a zero byte, or >= size if not found. Ideally, use lookahead -+ * to filter out any zero bytes that are known to not be followed by -+ * one or more further zero bytes and a one byte. Better still, filter -+ * out any bytes that form the trailing_zero_8bits syntax element too. -+ */ -+ int (*h264_find_start_code_candidate)(const uint8_t *buf, int size); - }H264DSPContext; - - void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); --- -1.8.1.6 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.03-arm-Add_assembly_version_of-h264_find_start_code_candidate.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.03-arm-Add_assembly_version_of-h264_find_start_code_candidate.patch deleted file mode 100644 index 57f50520b2..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-921.03-arm-Add_assembly_version_of-h264_find_start_code_candidate.patch +++ /dev/null @@ -1,321 +0,0 @@ -From 4b8f90c0702324a9fcc3909c8bf7d80f090c41ba Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Thu, 22 Aug 2013 14:39:21 +0100 -Subject: [PATCH] arm: Add assembly version of h264_find_start_code_candidate -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - - Before After - Mean StdDev Mean StdDev Change -This function 508.8 23.4 185.4 9.0 +174.4% -Overall 3068.5 31.7 2752.1 29.4 +11.5% - -In combination with the preceding patch: - Before After - Mean StdDev Mean StdDev Change -Overall 2925.6 26.2 2752.1 29.4 +6.3% - -Signed-off-by: Martin Storsjö ---- - libavcodec/arm/Makefile | 1 + - libavcodec/arm/h264dsp_armv6.S | 253 +++++++++++++++++++++++++++ - libavcodec/arm/h264dsp_init_arm.c | 4 + - 3 files changed, 258 insertions(+) - create mode 100644 libavcodec/arm/h264dsp_armv6.S - -diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile -index 798dfe3..8f2b683 100644 ---- a/libavcodec/arm/Makefile -+++ b/libavcodec/arm/Makefile -@@ -4,6 +4,7 @@ OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_init_arm.o \ - OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_init_arm.o \ - - ARMV6-OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_armv6.o -+ARMV6-OBJS-$(CONFIG_H264DSP) += arm/h264dsp_armv6.o - - OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_init_arm.o - ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_fixed_armv6.o -diff --git a/libavcodec/arm/h264dsp_armv6.S b/libavcodec/arm/h264dsp_armv6.S -new file mode 100644 -index 0000000..c2cafc2 ---- /dev/null -+++ b/libavcodec/arm/h264dsp_armv6.S -@@ -0,0 +1,253 @@ -+/* -+ * Copyright (c) 2013 RISC OS Open Ltd -+ * Author: Ben Avison -+ * -+ * This file is part of Libav. -+ * -+ * Libav is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * Libav is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with Libav; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+ -+#include "asm.S" -+ -+RESULT .req a1 -+BUF .req a1 -+SIZE .req a2 -+PATTERN .req a3 -+PTR .req a4 -+DAT0 .req v1 -+DAT1 .req v2 -+DAT2 .req v3 -+DAT3 .req v4 -+TMP0 .req v5 -+TMP1 .req v6 -+TMP2 .req ip -+TMP3 .req lr -+ -+#define PRELOAD_DISTANCE 4 -+ -+.macro innerloop4 -+ ldr DAT0, [PTR], #4 -+ subs SIZE, SIZE, #4 @ C flag survives rest of macro -+ sub TMP0, DAT0, PATTERN, lsr #14 -+ bic TMP0, TMP0, DAT0 -+ ands TMP0, TMP0, PATTERN -+.endm -+ -+.macro innerloop16 decrement, do_preload -+ ldmia PTR!, {DAT0,DAT1,DAT2,DAT3} -+ .ifnc "\do_preload","" -+ pld [PTR, #PRELOAD_DISTANCE*32] -+ .endif -+ .ifnc "\decrement","" -+ subs SIZE, SIZE, #\decrement @ C flag survives rest of macro -+ .endif -+ sub TMP0, DAT0, PATTERN, lsr #14 -+ sub TMP1, DAT1, PATTERN, lsr #14 -+ bic TMP0, TMP0, DAT0 -+ bic TMP1, TMP1, DAT1 -+ sub TMP2, DAT2, PATTERN, lsr #14 -+ sub TMP3, DAT3, PATTERN, lsr #14 -+ ands TMP0, TMP0, PATTERN -+ bic TMP2, TMP2, DAT2 -+ it eq -+ andseq TMP1, TMP1, PATTERN -+ bic TMP3, TMP3, DAT3 -+ itt eq -+ andseq TMP2, TMP2, PATTERN -+ andseq TMP3, TMP3, PATTERN -+.endm -+ -+/* int ff_h264_find_start_code_candidate_armv6(const uint8_t *buf, int size) */ -+function ff_h264_find_start_code_candidate_armv6, export=1 -+ push {v1-v6,lr} -+ mov PTR, BUF -+ @ Ensure there are at least (PRELOAD_DISTANCE+2) complete cachelines to go -+ @ before using code that does preloads -+ cmp SIZE, #(PRELOAD_DISTANCE+3)*32 - 1 -+ blo 60f -+ -+ @ Get to word-alignment, 1 byte at a time -+ tst PTR, #3 -+ beq 2f -+1: ldrb DAT0, [PTR], #1 -+ sub SIZE, SIZE, #1 -+ teq DAT0, #0 -+ beq 90f -+ tst PTR, #3 -+ bne 1b -+2: @ Get to 4-word alignment, 1 word at a time -+ ldr PATTERN, =0x80008000 -+ setend be -+ tst PTR, #12 -+ beq 4f -+3: innerloop4 -+ bne 91f -+ tst PTR, #12 -+ bne 3b -+4: @ Get to cacheline (8-word) alignment -+ tst PTR, #16 -+ beq 5f -+ innerloop16 16 -+ bne 93f -+5: @ Check complete cachelines, with preloading -+ @ We need to stop when there are still (PRELOAD_DISTANCE+1) -+ @ complete cachelines to go -+ sub SIZE, SIZE, #(PRELOAD_DISTANCE+2)*32 -+6: innerloop16 , do_preload -+ bne 93f -+ innerloop16 32 -+ bne 93f -+ bcs 6b -+ @ Preload trailing part-cacheline, if any -+ tst SIZE, #31 -+ beq 7f -+ pld [PTR, #(PRELOAD_DISTANCE+1)*32] -+ @ Check remaining data without doing any more preloads. First -+ @ do in chunks of 4 words: -+7: adds SIZE, SIZE, #(PRELOAD_DISTANCE+2)*32 - 16 -+ bmi 9f -+8: innerloop16 16 -+ bne 93f -+ bcs 8b -+ @ Then in words: -+9: adds SIZE, SIZE, #16 - 4 -+ bmi 11f -+10: innerloop4 -+ bne 91f -+ bcs 10b -+11: setend le -+ @ Check second byte of final halfword -+ ldrb DAT0, [PTR, #-1] -+ teq DAT0, #0 -+ beq 90f -+ @ Check any remaining bytes -+ tst SIZE, #3 -+ beq 13f -+12: ldrb DAT0, [PTR], #1 -+ sub SIZE, SIZE, #1 -+ teq DAT0, #0 -+ beq 90f -+ tst SIZE, #3 -+ bne 12b -+ @ No candidate found -+13: sub RESULT, PTR, BUF -+ b 99f -+ -+60: @ Small buffer - simply check by looping over bytes -+ subs SIZE, SIZE, #1 -+ bcc 99f -+61: ldrb DAT0, [PTR], #1 -+ subs SIZE, SIZE, #1 -+ teq DAT0, #0 -+ beq 90f -+ bcs 61b -+ @ No candidate found -+ sub RESULT, PTR, BUF -+ b 99f -+ -+90: @ Found a candidate at the preceding byte -+ sub RESULT, PTR, BUF -+ sub RESULT, RESULT, #1 -+ b 99f -+ -+91: @ Found a candidate somewhere in the preceding 4 bytes -+ sub RESULT, PTR, BUF -+ sub RESULT, RESULT, #4 -+ sub TMP0, DAT0, #0x20000 -+ bics TMP0, TMP0, DAT0 -+ itt pl -+ ldrbpl DAT0, [PTR, #-3] -+ addpl RESULT, RESULT, #2 -+ bpl 92f -+ teq RESULT, #0 -+ beq 98f @ don't look back a byte if found at first byte in buffer -+ ldrb DAT0, [PTR, #-5] -+92: teq DAT0, #0 -+ it eq -+ subeq RESULT, RESULT, #1 -+ b 98f -+ -+93: @ Found a candidate somewhere in the preceding 16 bytes -+ sub RESULT, PTR, BUF -+ sub RESULT, RESULT, #16 -+ teq TMP0, #0 -+ beq 95f @ not in first 4 bytes -+ sub TMP0, DAT0, #0x20000 -+ bics TMP0, TMP0, DAT0 -+ itt pl -+ ldrbpl DAT0, [PTR, #-15] -+ addpl RESULT, RESULT, #2 -+ bpl 94f -+ teq RESULT, #0 -+ beq 98f @ don't look back a byte if found at first byte in buffer -+ ldrb DAT0, [PTR, #-17] -+94: teq DAT0, #0 -+ it eq -+ subeq RESULT, RESULT, #1 -+ b 98f -+95: add RESULT, RESULT, #4 -+ teq TMP1, #0 -+ beq 96f @ not in next 4 bytes -+ sub TMP1, DAT1, #0x20000 -+ bics TMP1, TMP1, DAT1 -+ itee mi -+ ldrbmi DAT0, [PTR, #-13] -+ ldrbpl DAT0, [PTR, #-11] -+ addpl RESULT, RESULT, #2 -+ teq DAT0, #0 -+ it eq -+ subeq RESULT, RESULT, #1 -+ b 98f -+96: add RESULT, RESULT, #4 -+ teq TMP2, #0 -+ beq 97f @ not in next 4 bytes -+ sub TMP2, DAT2, #0x20000 -+ bics TMP2, TMP2, DAT2 -+ itee mi -+ ldrbmi DAT0, [PTR, #-9] -+ ldrbpl DAT0, [PTR, #-7] -+ addpl RESULT, RESULT, #2 -+ teq DAT0, #0 -+ it eq -+ subeq RESULT, RESULT, #1 -+ b 98f -+97: add RESULT, RESULT, #4 -+ sub TMP3, DAT3, #0x20000 -+ bics TMP3, TMP3, DAT3 -+ itee mi -+ ldrbmi DAT0, [PTR, #-5] -+ ldrbpl DAT0, [PTR, #-3] -+ addpl RESULT, RESULT, #2 -+ teq DAT0, #0 -+ it eq -+ subeq RESULT, RESULT, #1 -+ @ drop through to 98f -+98: setend le -+99: pop {v1-v6,pc} -+.endfunc -+ -+ .unreq RESULT -+ .unreq BUF -+ .unreq SIZE -+ .unreq PATTERN -+ .unreq PTR -+ .unreq DAT0 -+ .unreq DAT1 -+ .unreq DAT2 -+ .unreq DAT3 -+ .unreq TMP0 -+ .unreq TMP1 -+ .unreq TMP2 -+ .unreq TMP3 -diff --git a/libavcodec/arm/h264dsp_init_arm.c b/libavcodec/arm/h264dsp_init_arm.c -index cc4c688..c282c21 100644 ---- a/libavcodec/arm/h264dsp_init_arm.c -+++ b/libavcodec/arm/h264dsp_init_arm.c -@@ -23,6 +23,8 @@ - #include "libavcodec/dsputil.h" - #include "libavcodec/h264dsp.h" - -+int ff_h264_find_start_code_candidate_armv6(const uint8_t *buf, int size); -+ - void ff_h264_v_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha, - int beta, int8_t *tc0); - void ff_h264_h_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha, -@@ -99,5 +101,7 @@ static void ff_h264dsp_init_neon(H264DSPContext *c, const int bit_depth, const i - - void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) - { -+ if (HAVE_ARMV6) -+ c->h264_find_start_code_candidate = ff_h264_find_start_code_candidate_armv6; - if (HAVE_NEON) ff_h264dsp_init_neon(c, bit_depth, chroma_format_idc); - } --- -1.8.1.6 - diff --git a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-999.udp.patch b/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-999.udp.patch deleted file mode 100644 index 5f8f0456e9..0000000000 --- a/packages/multimedia/ffmpeg/patches/0.10.7/ffmpeg-0.10.6-999.udp.patch +++ /dev/null @@ -1,122 +0,0 @@ -From eff39646c73e74124621120bdcdccec4d62db61f Mon Sep 17 00:00:00 2001 -From: Michael Niedermayer -Date: Thu, 23 Feb 2012 23:22:16 +0100 -Subject: [PATCH 2/5] udp: Fix sign of error codes. - -Signed-off-by: Michael Niedermayer ---- - libavformat/udp.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/libavformat/udp.c b/libavformat/udp.c -index 9694ad2..309b18c 100644 ---- a/libavformat/udp.c -+++ b/libavformat/udp.c -@@ -335,7 +335,7 @@ static void *circular_buffer_task( void *_URLContext) - int len; - - if (ff_check_interrupt(&h->interrupt_callback)) { -- s->circular_buffer_error = EINTR; -+ s->circular_buffer_error = AVERROR(EINTR); - goto end; - } - -@@ -347,7 +347,7 @@ static void *circular_buffer_task( void *_URLContext) - if (ret < 0) { - if (ff_neterrno() == AVERROR(EINTR)) - continue; -- s->circular_buffer_error = EIO; -+ s->circular_buffer_error = AVERROR(EIO); - goto end; - } - -@@ -361,14 +361,14 @@ static void *circular_buffer_task( void *_URLContext) - /* No Space left, error, what do we do now */ - if(left < UDP_MAX_PKT_SIZE + 4) { - av_log(h, AV_LOG_ERROR, "circular_buffer: OVERRUN\n"); -- s->circular_buffer_error = EIO; -+ s->circular_buffer_error = AVERROR(EIO); - goto end; - } - left = FFMIN(left, s->fifo->end - s->fifo->wptr); - len = recv(s->udp_fd, s->tmp+4, sizeof(s->tmp)-4, 0); - if (len < 0) { - if (ff_neterrno() != AVERROR(EAGAIN) && ff_neterrno() != AVERROR(EINTR)) { -- s->circular_buffer_error = EIO; -+ s->circular_buffer_error = AVERROR(EIO); - goto end; - } - continue; --- -1.8.1.5 - - -From 13abee9310f7dd5982e9a0c5fde9b7f2a0ad9ce0 Mon Sep 17 00:00:00 2001 -From: Nicolas George -Date: Thu, 15 Mar 2012 12:19:37 +0100 -Subject: [PATCH 3/5] udp: fix non-blocking and interrupt handling. - -In non-blocking mode, lowest-level read protocols are -supposed block only for a short amount of time to let -retry_transfer_wrapper() check for interrupts. - -Also, checking the interrupt_callback in the receiving thread is -wrong, as interrupt_callback is not guaranteed to be thread-safe -and the job is already done by retry_transfer_wrapper(). The error -code was also incorrect. - -Bug reported by Andrey Utkin. ---- - libavformat/udp.c | 18 ++++++++++-------- - 1 file changed, 10 insertions(+), 8 deletions(-) - -diff --git a/libavformat/udp.c b/libavformat/udp.c -index 309b18c..ed1559d 100644 ---- a/libavformat/udp.c -+++ b/libavformat/udp.c -@@ -334,11 +334,6 @@ static void *circular_buffer_task( void *_URLContext) - int ret; - int len; - -- if (ff_check_interrupt(&h->interrupt_callback)) { -- s->circular_buffer_error = AVERROR(EINTR); -- goto end; -- } -- - FD_ZERO(&rfds); - FD_SET(s->udp_fd, &rfds); - tv.tv_sec = 1; -@@ -568,7 +563,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size) - { - UDPContext *s = h->priv_data; - int ret; -- int avail; -+ int avail, nonblock = h->flags & AVIO_FLAG_NONBLOCK; - - #if HAVE_PTHREADS - if (s->fifo) { -@@ -592,12 +587,19 @@ static int udp_read(URLContext *h, uint8_t *buf, int size) - } else if(s->circular_buffer_error){ - pthread_mutex_unlock(&s->mutex); - return s->circular_buffer_error; -- } else if(h->flags & AVIO_FLAG_NONBLOCK) { -+ } else if(nonblock) { - pthread_mutex_unlock(&s->mutex); - return AVERROR(EAGAIN); - } - else { -- pthread_cond_wait(&s->cond, &s->mutex); -+ /* FIXME: using the monotonic clock would be better, -+ but it does not exist on all supported platforms. */ -+ int64_t t = av_gettime() + 100000; -+ struct timespec tv = { .tv_sec = t / 1000000, -+ .tv_nsec = (t % 1000000) * 1000 }; -+ if (pthread_cond_timedwait(&s->cond, &s->mutex, &tv) < 0) -+ return AVERROR(errno == ETIMEDOUT ? EAGAIN : errno); -+ nonblock = 1; - } - } while( 1); - } --- -1.8.1.5 -