diff options
author | Bradley Sepos <[email protected]> | 2016-10-26 14:56:39 -0400 |
---|---|---|
committer | John Stebbins <[email protected]> | 2016-12-17 07:28:51 -0800 |
commit | 2490f8ecf56a6aa1dafbd59682b82b326aeb20e8 (patch) | |
tree | ceee7e5749b0569163856e99de57d3f22a7f7bf3 | |
parent | c4d539e1791b3fcc3788c4c7656abe55675267b0 (diff) |
contrib: Update to Libav 12.
-rw-r--r-- | contrib/ffmpeg/A01-matroskaenc-pgs-duration.patch (renamed from contrib/ffmpeg/A07-matroskaenc-pgs-duration.patch) | 0 | ||||
-rw-r--r-- | contrib/ffmpeg/A01-mkv-forced-flag.patch | 13 | ||||
-rw-r--r-- | contrib/ffmpeg/A02-strptime.patch | 134 | ||||
-rw-r--r-- | contrib/ffmpeg/A03-dxva2-hevc.patch | 1145 | ||||
-rw-r--r-- | contrib/ffmpeg/A04-dxtory.patch | 685 | ||||
-rw-r--r-- | contrib/ffmpeg/A05-matroskaenc-track-lang.patch | 15 | ||||
-rw-r--r-- | contrib/ffmpeg/A06-vc1-decode.patch | 28 | ||||
-rw-r--r-- | contrib/ffmpeg/A08-mov-audio-fallback.patch | 119 | ||||
-rw-r--r-- | contrib/ffmpeg/A09-atmos-substream.patch | 181 | ||||
-rw-r--r-- | contrib/ffmpeg/A10-dcadec-false-overread.patch | 23 | ||||
-rw-r--r-- | contrib/ffmpeg/A11-vf-pad.patch | 34 | ||||
-rw-r--r-- | contrib/ffmpeg/A12-avfilter-framerate.patch | 352 | ||||
-rw-r--r-- | contrib/ffmpeg/A13-avi-dv.patch | 37 | ||||
-rw-r--r-- | contrib/ffmpeg/A14-eac3-request-sample.patch | 87 | ||||
-rw-r--r-- | contrib/ffmpeg/A15-vp9.patch | 27 | ||||
-rw-r--r-- | contrib/ffmpeg/module.defs | 10 |
16 files changed, 3 insertions, 2887 deletions
diff --git a/contrib/ffmpeg/A07-matroskaenc-pgs-duration.patch b/contrib/ffmpeg/A01-matroskaenc-pgs-duration.patch index 9463905c8..9463905c8 100644 --- a/contrib/ffmpeg/A07-matroskaenc-pgs-duration.patch +++ b/contrib/ffmpeg/A01-matroskaenc-pgs-duration.patch diff --git a/contrib/ffmpeg/A01-mkv-forced-flag.patch b/contrib/ffmpeg/A01-mkv-forced-flag.patch deleted file mode 100644 index e18590d50..000000000 --- a/contrib/ffmpeg/A01-mkv-forced-flag.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c -index cab43f4..8688616 100644 ---- a/libavformat/matroskaenc.c -+++ b/libavformat/matroskaenc.c -@@ -769,6 +769,8 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, - // if we need to clear it. - if (!(st->disposition & AV_DISPOSITION_DEFAULT)) - put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & AV_DISPOSITION_DEFAULT)); -+ if (st->disposition & AV_DISPOSITION_FORCED) -+ put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGFORCED, !!(st->disposition & AV_DISPOSITION_FORCED)); - - if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->initial_padding) { - mkv->tracks[i].ts_offset = av_rescale_q(codec->initial_padding, diff --git a/contrib/ffmpeg/A02-strptime.patch b/contrib/ffmpeg/A02-strptime.patch deleted file mode 100644 index 9b49dd714..000000000 --- a/contrib/ffmpeg/A02-strptime.patch +++ /dev/null @@ -1,134 +0,0 @@ -diff --git a/configure b/configure -index 33a7a85..0a93664 100755 ---- a/configure -+++ b/configure -@@ -1467,7 +1467,6 @@ SYSTEM_FUNCS=" - setrlimit - Sleep - strerror_r -- strptime - sysconf - sysctl - usleep -@@ -4056,7 +4055,6 @@ check_func_headers time.h nanosleep || { check_func_headers time.h nanosleep -lr - check_func sched_getaffinity - check_func setrlimit - check_func strerror_r --check_func strptime - check_func sysconf - check_func sysctl - check_func usleep -diff --git a/libavformat/utils.c b/libavformat/utils.c -index 94431e1..9626260 100644 ---- a/libavformat/utils.c -+++ b/libavformat/utils.c -@@ -2914,21 +2914,14 @@ int ff_find_stream_index(AVFormatContext *s, int id) - - int64_t ff_iso8601_to_unix_time(const char *datestr) - { --#if HAVE_STRPTIME - struct tm time1 = { 0 }, time2 = { 0 }; - char *ret1, *ret2; -- ret1 = strptime(datestr, "%Y - %m - %d %T", &time1); -- ret2 = strptime(datestr, "%Y - %m - %dT%T", &time2); -+ ret1 = av_small_strptime(datestr, "%Y - %m - %d %H:%M:%S", &time1); -+ ret2 = av_small_strptime(datestr, "%Y - %m - %dT%H:%M:%S", &time2); - if (ret2 && !ret1) - return av_timegm(&time2); - else - return av_timegm(&time1); --#else -- av_log(NULL, AV_LOG_WARNING, -- "strptime() unavailable on this system, cannot convert " -- "the date string.\n"); -- return 0; --#endif - } - - int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, -diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c -index 414cd47..89d0ff9 100644 ---- a/libavutil/parseutils.c -+++ b/libavutil/parseutils.c -@@ -399,11 +399,17 @@ static int date_get_num(const char **pp, - return val; - } - --static const char *small_strptime(const char *p, const char *fmt, struct tm *dt) -+const char *av_small_strptime(const char *p, const char *fmt, struct tm *dt) - { - int c, val; - - for(;;) { -+ /* consume time string until a non whitespace char is found */ -+ while (av_isspace(*fmt)) { -+ while (av_isspace(*p)) -+ p++; -+ fmt++; -+ } - c = *fmt++; - if (c == '\0') { - return p; -@@ -517,7 +523,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration) - - /* parse the year-month-day part */ - for (i = 0; i < FF_ARRAY_ELEMS(date_fmt); i++) { -- q = small_strptime(p, date_fmt[i], &dt); -+ q = av_small_strptime(p, date_fmt[i], &dt); - if (q) { - break; - } -@@ -541,7 +547,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration) - - /* parse the hour-minute-second part */ - for (i = 0; i < FF_ARRAY_ELEMS(time_fmt); i++) { -- q = small_strptime(p, time_fmt[i], &dt); -+ q = av_small_strptime(p, time_fmt[i], &dt); - if (q) { - break; - } -@@ -553,7 +559,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration) - ++p; - } - /* parse timestr as HH:MM:SS */ -- q = small_strptime(p, time_fmt[0], &dt); -+ q = av_small_strptime(p, time_fmt[0], &dt); - if (!q) { - char *o; - /* parse timestr as S+ */ -diff --git a/libavutil/parseutils.h b/libavutil/parseutils.h -index 0844abb..94751d1 100644 ---- a/libavutil/parseutils.h -+++ b/libavutil/parseutils.h -@@ -109,6 +109,31 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, - int av_parse_time(int64_t *timeval, const char *timestr, int duration); - - /** -+ * Parse the input string p according to the format string fmt and -+ * store its results in the structure dt. -+ * This implementation supports only a subset of the formats supported -+ * by the standard strptime(). -+ * -+ * In particular it actually supports the parameters: -+ * - %H: the hour as a decimal number, using a 24-hour clock, in the -+ * range '00' through '23' -+ * - %M: the minute as a decimal number, using a 24-hour clock, in the -+ * range '00' through '59' -+ * - %S: the second as a decimal number, using a 24-hour clock, in the -+ * range '00' through '59' -+ * - %Y: the year as a decimal number, using the Gregorian calendar -+ * - %m: the month as a decimal number, in the range '1' through '12' -+ * - %d: the day of the month as a decimal number, in the range '1' -+ * through '31' -+ * - %%: a literal '%' -+ * -+ * @return a pointer to the first character not processed in this -+ * function call, or NULL in case the function fails to match all of -+ * the fmt string and therefore an error occurred -+ */ -+const char *av_small_strptime(const char *p, const char *fmt, struct tm *dt); -+ -+/** - * Attempt to find a specific tag in a URL. - * - * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done. diff --git a/contrib/ffmpeg/A03-dxva2-hevc.patch b/contrib/ffmpeg/A03-dxva2-hevc.patch deleted file mode 100644 index 82f71b5f3..000000000 --- a/contrib/ffmpeg/A03-dxva2-hevc.patch +++ /dev/null @@ -1,1145 +0,0 @@ -From a99d16e600f9070a3bcb99151d7fc3508d2fca59 Mon Sep 17 00:00:00 2001 -From: Diego Biurrun <[email protected]> -Date: Fri, 15 Aug 2014 20:51:01 +0200 -Subject: [PATCH 1/9] dxva2: Pass variable of correct type to - IDirectXVideoDecoder_GetBuffer() - -This avoids related incompatible pointer type warnings. - -(cherry picked from commit 4600a85eaa6182e5a27464f6b9cae5a9ddbf3098) ---- - libavcodec/dxva2_h264.c | 7 +++++-- - libavcodec/dxva2_mpeg2.c | 5 ++++- - libavcodec/dxva2_vc1.c | 4 +++- - 3 files changed, 12 insertions(+), 4 deletions(-) - -diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c -index fa205c4..4132cd7 100644 ---- a/libavcodec/dxva2_h264.c -+++ b/libavcodec/dxva2_h264.c -@@ -297,6 +297,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, - const H264Picture *current_picture = h->cur_pic_ptr; - struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; - DXVA_Slice_H264_Short *slice = NULL; -+ void *dxva_data_ptr; - uint8_t *dxva_data, *current, *end; - unsigned dxva_size; - void *slice_data; -@@ -306,9 +307,11 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, - - /* Create an annex B bitstream buffer with only slice NAL and finalize slice */ - if (FAILED(IDirectXVideoDecoder_GetBuffer(ctx->decoder, -- DXVA2_BitStreamDateBufferType, -- &dxva_data, &dxva_size))) -+ DXVA2_BitStreamDateBufferType, -+ &dxva_data_ptr, &dxva_size))) - return -1; -+ -+ dxva_data = dxva_data_ptr; - current = dxva_data; - end = dxva_data + dxva_size; - -diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c -index f6ef5e5..65624e3 100644 ---- a/libavcodec/dxva2_mpeg2.c -+++ b/libavcodec/dxva2_mpeg2.c -@@ -156,14 +156,17 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, - s->current_picture_ptr->hwaccel_picture_private; - const int is_field = s->picture_structure != PICT_FRAME; - const unsigned mb_count = s->mb_width * (s->mb_height >> is_field); -+ void *dxva_data_ptr; - uint8_t *dxva_data, *current, *end; - unsigned dxva_size; - unsigned i; - - if (FAILED(IDirectXVideoDecoder_GetBuffer(ctx->decoder, - DXVA2_BitStreamDateBufferType, -- &dxva_data, &dxva_size))) -+ &dxva_data_ptr, &dxva_size))) - return -1; -+ -+ dxva_data = dxva_data_ptr; - current = dxva_data; - end = dxva_data + dxva_size; - -diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c -index 4f4dd17..1524b51 100644 ---- a/libavcodec/dxva2_vc1.c -+++ b/libavcodec/dxva2_vc1.c -@@ -173,15 +173,17 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, - const unsigned padding = 128 - ((start_code_size + slice_size) & 127); - const unsigned data_size = start_code_size + slice_size + padding; - -+ void *dxva_data_ptr; - uint8_t *dxva_data; - unsigned dxva_size; - int result; - - if (FAILED(IDirectXVideoDecoder_GetBuffer(ctx->decoder, - DXVA2_BitStreamDateBufferType, -- &dxva_data, &dxva_size))) -+ &dxva_data_ptr, &dxva_size))) - return -1; - -+ dxva_data = dxva_data_ptr; - result = data_size <= dxva_size ? 0 : -1; - if (!result) { - if (start_code_size > 0) --- -2.3.2 (Apple Git-55) - - -From 13d8656eb3352c30a7e6983caa0f721b2df317df Mon Sep 17 00:00:00 2001 -From: Diego Biurrun <[email protected]> -Date: Fri, 15 Aug 2014 21:01:15 +0200 -Subject: [PATCH 2/9] dxva2: Clean up definition of _WIN32_WINNT - -Only set a value if _WIN32_WINNT is undefined or smaller than 0x0600. This is -cleaner than unconditional definition and avoids a number of redefinition -warnings. Also only define a value in one of the two dxva2 headers. - -(cherry picked from commit b8962d64cc71af241601bcab5c3fcdc5735ef4ae) ---- - libavcodec/dxva2.h | 4 ++++ - libavcodec/dxva2_internal.h | 1 - - 2 files changed, 4 insertions(+), 1 deletion(-) - -diff --git a/libavcodec/dxva2.h b/libavcodec/dxva2.h -index 78939be..d9017c6 100644 ---- a/libavcodec/dxva2.h -+++ b/libavcodec/dxva2.h -@@ -29,7 +29,11 @@ - * Public libavcodec DXVA2 header. - */ - -+#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 -+#undef _WIN32_WINNT - #define _WIN32_WINNT 0x0600 -+#endif -+ - #include <stdint.h> - #include <d3d9.h> - #include <dxva2api.h> -diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h -index f35a076..b775e6c 100644 ---- a/libavcodec/dxva2_internal.h -+++ b/libavcodec/dxva2_internal.h -@@ -23,7 +23,6 @@ - #ifndef AVCODEC_DXVA_INTERNAL_H - #define AVCODEC_DXVA_INTERNAL_H - --#define _WIN32_WINNT 0x0600 - #define COBJMACROS - - #include "config.h" --- -2.3.2 (Apple Git-55) - - -From 56af8c0a6c9d1b05b11ba2be6fbacac4956abbef Mon Sep 17 00:00:00 2001 -From: Hendrik Leppkes <[email protected]> -Date: Sun, 25 Jan 2015 12:58:45 +0100 -Subject: [PATCH 3/9] hevc: pass the full HEVCNAL struct to decode_nal_unit - -This enables decode_nal_unit to access additional fields added in -subsequent commits. - -Signed-off-by: Anton Khirnov <[email protected]> -(cherry picked from commit b0593a4bca138f1f026d8c21e8c3daa96800afe2) ---- - libavcodec/hevc.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c -index 21d437c..6cd9054 100644 ---- a/libavcodec/hevc.c -+++ b/libavcodec/hevc.c -@@ -2490,13 +2490,13 @@ fail: - return ret; - } - --static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length) -+static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal) - { - HEVCLocalContext *lc = &s->HEVClc; - GetBitContext *gb = &lc->gb; - int ctb_addr_ts, ret; - -- ret = init_get_bits8(gb, nal, length); -+ ret = init_get_bits8(gb, nal->data, nal->size); - if (ret < 0) - return ret; - -@@ -2802,7 +2802,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) - - /* parse the NAL units */ - for (i = 0; i < s->nb_nals; i++) { -- int ret = decode_nal_unit(s, s->nals[i].data, s->nals[i].size); -+ int ret = decode_nal_unit(s, &s->nals[i]); - if (ret < 0) { - av_log(s->avctx, AV_LOG_WARNING, - "Error parsing NAL unit #%d.\n", i); --- -2.3.2 (Apple Git-55) - - -From 60a65b94510cdda380ebbcf43812e6302697f2f7 Mon Sep 17 00:00:00 2001 -From: Hendrik Leppkes <[email protected]> -Date: Sun, 25 Jan 2015 12:58:46 +0100 -Subject: [PATCH 4/9] hevc: store the escaped/raw bitstream in HEVCNAL - -Hardware Accelerators require access to the escaped bitstream. - -Signed-off-by: Anton Khirnov <[email protected]> -(cherry picked from commit 36779a84051eae6744cc936d91b1d428143665ba) ---- - libavcodec/hevc.c | 8 ++++++-- - libavcodec/hevc.h | 3 +++ - 2 files changed, 9 insertions(+), 2 deletions(-) - -diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c -index 6cd9054..8371b6b 100644 ---- a/libavcodec/hevc.c -+++ b/libavcodec/hevc.c -@@ -2682,8 +2682,10 @@ static int extract_rbsp(const uint8_t *src, int length, - #endif /* HAVE_FAST_UNALIGNED */ - - if (i >= length - 1) { // no escaped 0 -- nal->data = src; -- nal->size = length; -+ nal->data = -+ nal->raw_data = src; -+ nal->size = -+ nal->raw_size = length; - return length; - } - -@@ -2722,6 +2724,8 @@ nsc: - - nal->data = dst; - nal->size = di; -+ nal->raw_data = src; -+ nal->raw_size = si; - return si; - } - -diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h -index 93c5125..94c688e 100644 ---- a/libavcodec/hevc.h -+++ b/libavcodec/hevc.h -@@ -696,6 +696,9 @@ typedef struct HEVCNAL { - - int size; - const uint8_t *data; -+ -+ int raw_size; -+ const uint8_t *raw_data; - } HEVCNAL; - - struct HEVCContext; --- -2.3.2 (Apple Git-55) - - -From bfa5b2620e89fc67782e712555d332c0813a9225 Mon Sep 17 00:00:00 2001 -From: Hendrik Leppkes <[email protected]> -Date: Sun, 25 Jan 2015 12:58:47 +0100 -Subject: [PATCH 5/9] hevc: store the short term rps flag and size in the - context - -For future use by hardware accelerators. - -Signed-off-by: Anton Khirnov <[email protected]> -(cherry picked from commit 4b95e95dbae58c9b60891284bf8b5bbd83e5293a) ---- - libavcodec/hevc.c | 8 +++++--- - libavcodec/hevc.h | 2 ++ - 2 files changed, 7 insertions(+), 3 deletions(-) - -diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c -index 8371b6b..18de9e5 100644 ---- a/libavcodec/hevc.c -+++ b/libavcodec/hevc.c -@@ -552,7 +552,7 @@ static int hls_slice_header(HEVCContext *s) - sh->colour_plane_id = get_bits(gb, 2); - - if (!IS_IDR(s)) { -- int short_term_ref_pic_set_sps_flag, poc; -+ int poc; - - sh->pic_order_cnt_lsb = get_bits(gb, s->sps->log2_max_poc_lsb); - poc = ff_hevc_compute_poc(s, sh->pic_order_cnt_lsb); -@@ -565,12 +565,14 @@ static int hls_slice_header(HEVCContext *s) - } - s->poc = poc; - -- short_term_ref_pic_set_sps_flag = get_bits1(gb); -- if (!short_term_ref_pic_set_sps_flag) { -+ sh->short_term_ref_pic_set_sps_flag = get_bits1(gb); -+ if (!sh->short_term_ref_pic_set_sps_flag) { -+ int pos = get_bits_left(gb); - ret = ff_hevc_decode_short_term_rps(s, &sh->slice_rps, s->sps, 1); - if (ret < 0) - return ret; - -+ sh->short_term_ref_pic_set_size = pos - get_bits_left(gb); - sh->short_term_rps = &sh->slice_rps; - } else { - int numbits, rps_idx; -diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h -index 94c688e..dced2b4 100644 ---- a/libavcodec/hevc.h -+++ b/libavcodec/hevc.h -@@ -543,6 +543,8 @@ typedef struct SliceHeader { - uint8_t colour_plane_id; - - ///< RPS coded in the slice header itself is stored here -+ int short_term_ref_pic_set_sps_flag; -+ int short_term_ref_pic_set_size; - ShortTermRPS slice_rps; - const ShortTermRPS *short_term_rps; - LongTermRPS long_term_rps; --- -2.3.2 (Apple Git-55) - - -From 3d85f38f870bce16c26bd8ebd80de1d22b940ce6 Mon Sep 17 00:00:00 2001 -From: Hendrik Leppkes <[email protected]> -Date: Sun, 25 Jan 2015 12:58:48 +0100 -Subject: [PATCH 6/9] hevc: add hwaccel hooks - -Signed-off-by: Anton Khirnov <[email protected]> -(cherry picked from commit e72e8c5a1df61447ac7af750531e96e8b62d02ba) ---- - libavcodec/hevc.c | 38 ++++++++++++++++++++++++++++++++++++-- - libavcodec/hevc.h | 3 +++ - libavcodec/hevc_refs.c | 17 +++++++++++++++++ - 3 files changed, 56 insertions(+), 2 deletions(-) - -diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c -index 18de9e5..2d1acdb5 100644 ---- a/libavcodec/hevc.c -+++ b/libavcodec/hevc.c -@@ -385,6 +385,8 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) - - static int set_sps(HEVCContext *s, const HEVCSPS *sps) - { -+ #define HWACCEL_MAX (0) -+ enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; - int ret; - unsigned int num = 0, den = 0; - -@@ -397,9 +399,16 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps) - s->avctx->coded_height = sps->height; - s->avctx->width = sps->output_width; - s->avctx->height = sps->output_height; -- s->avctx->pix_fmt = sps->pix_fmt; - s->avctx->has_b_frames = sps->temporal_layer[sps->max_sub_layers - 1].num_reorder_pics; - -+ *fmt++ = sps->pix_fmt; -+ *fmt = AV_PIX_FMT_NONE; -+ -+ ret = ff_get_format(s->avctx, pix_fmts); -+ if (ret < 0) -+ goto fail; -+ s->avctx->pix_fmt = ret; -+ - ff_set_sar(s->avctx, sps->vui.sar); - - if (sps->vui.video_signal_type_present_flag) -@@ -422,7 +431,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps) - ff_hevc_dsp_init (&s->hevcdsp, sps->bit_depth); - ff_videodsp_init (&s->vdsp, sps->bit_depth); - -- if (sps->sao_enabled) { -+ if (sps->sao_enabled && !s->avctx->hwaccel) { - av_frame_unref(s->tmp_frame); - ret = ff_get_buffer(s->avctx, s->tmp_frame, AV_GET_BUFFER_FLAG_REF); - if (ret < 0) -@@ -2596,6 +2605,17 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal) - } - } - -+ if (s->sh.first_slice_in_pic_flag && s->avctx->hwaccel) { -+ ret = s->avctx->hwaccel->start_frame(s->avctx, NULL, 0); -+ if (ret < 0) -+ goto fail; -+ } -+ -+ if (s->avctx->hwaccel) { -+ ret = s->avctx->hwaccel->decode_slice(s->avctx, nal->raw_data, nal->raw_size); -+ if (ret < 0) -+ goto fail; -+ } else { - ctb_addr_ts = hls_slice_data(s); - if (ctb_addr_ts >= (s->sps->ctb_width * s->sps->ctb_height)) { - s->is_decoded = 1; -@@ -2609,6 +2629,7 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal) - ret = ctb_addr_ts; - goto fail; - } -+ } - break; - case NAL_EOS_NUT: - case NAL_EOB_NUT: -@@ -2916,6 +2937,11 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, - if (ret < 0) - return ret; - -+ if (avctx->hwaccel) { -+ if (s->ref && avctx->hwaccel->end_frame(avctx) < 0) -+ av_log(avctx, AV_LOG_ERROR, -+ "hardware accelerator failed to decode picture\n"); -+ } else { - /* verify the SEI checksum */ - if (avctx->err_recognition & AV_EF_CRCCHECK && s->is_decoded && - s->is_md5) { -@@ -2925,6 +2951,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, - return ret; - } - } -+ } - s->is_md5 = 0; - - if (s->is_decoded) { -@@ -2966,6 +2993,13 @@ static int hevc_ref_frame(HEVCContext *s, HEVCFrame *dst, HEVCFrame *src) - dst->flags = src->flags; - dst->sequence = src->sequence; - -+ if (src->hwaccel_picture_private) { -+ dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); -+ if (!dst->hwaccel_priv_buf) -+ goto fail; -+ dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; -+ } -+ - return 0; - fail: - ff_hevc_unref_frame(s, dst, ~0); -diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h -index dced2b4..40e945e 100644 ---- a/libavcodec/hevc.h -+++ b/libavcodec/hevc.h -@@ -680,6 +680,9 @@ typedef struct HEVCFrame { - AVBufferRef *rpl_tab_buf; - AVBufferRef *rpl_buf; - -+ AVBufferRef *hwaccel_priv_buf; -+ void *hwaccel_picture_private; -+ - /** - * A sequence counter, so that old frames are output first - * after a POC reset -diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c -index 658ead7..0b8e4ef 100644 ---- a/libavcodec/hevc_refs.c -+++ b/libavcodec/hevc_refs.c -@@ -21,6 +21,7 @@ - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -+#include "libavutil/avassert.h" - #include "libavutil/pixdesc.h" - - #include "internal.h" -@@ -46,6 +47,9 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags) - frame->refPicList = NULL; - - frame->collocated_ref = NULL; -+ -+ av_buffer_unref(&frame->hwaccel_priv_buf); -+ frame->hwaccel_picture_private = NULL; - } - } - -@@ -105,6 +109,17 @@ static HEVCFrame *alloc_frame(HEVCContext *s) - for (j = 0; j < frame->ctb_count; j++) - frame->rpl_tab[j] = (RefPicListTab *)frame->rpl_buf->data; - -+ if (s->avctx->hwaccel) { -+ const AVHWAccel *hwaccel = s->avctx->hwaccel; -+ av_assert0(!frame->hwaccel_picture_private); -+ if (hwaccel->frame_priv_data_size) { -+ frame->hwaccel_priv_buf = av_buffer_allocz(hwaccel->frame_priv_data_size); -+ if (!frame->hwaccel_priv_buf) -+ goto fail; -+ frame->hwaccel_picture_private = frame->hwaccel_priv_buf->data; -+ } -+ } -+ - return frame; - - fail: -@@ -340,6 +355,7 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) - if (!frame) - return NULL; - -+ if (!s->avctx->hwaccel) { - if (!s->sps->pixel_shift) { - for (i = 0; frame->frame->buf[i]; i++) - memset(frame->frame->buf[i]->data, 1 << (s->sps->bit_depth - 1), -@@ -352,6 +368,7 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) - 1 << (s->sps->bit_depth - 1)); - } - } -+ } - - frame->poc = poc; - frame->sequence = s->seq_decode; --- -2.3.2 (Apple Git-55) - - -From f307d5762ae47dac503fe759f0774d25be9d7684 Mon Sep 17 00:00:00 2001 -From: Hendrik Leppkes <[email protected]> -Date: Sun, 25 Jan 2015 12:58:49 +0100 -Subject: [PATCH 7/9] hevc: reindent after previous commit - -Signed-off-by: Anton Khirnov <[email protected]> -(cherry picked from commit b82722df9b2911bd41e0928db4804067b39e6528) ---- - libavcodec/hevc.c | 40 ++++++++++++++++++++-------------------- - libavcodec/hevc_refs.c | 24 ++++++++++++------------ - 2 files changed, 32 insertions(+), 32 deletions(-) - -diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c -index 2d1acdb5..81f0dc8 100644 ---- a/libavcodec/hevc.c -+++ b/libavcodec/hevc.c -@@ -2616,19 +2616,19 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal) - if (ret < 0) - goto fail; - } else { -- ctb_addr_ts = hls_slice_data(s); -- if (ctb_addr_ts >= (s->sps->ctb_width * s->sps->ctb_height)) { -- s->is_decoded = 1; -- if ((s->pps->transquant_bypass_enable_flag || -- (s->sps->pcm.loop_filter_disable_flag && s->sps->pcm_enabled_flag)) && -- s->sps->sao_enabled) -- restore_tqb_pixels(s); -- } -+ ctb_addr_ts = hls_slice_data(s); -+ if (ctb_addr_ts >= (s->sps->ctb_width * s->sps->ctb_height)) { -+ s->is_decoded = 1; -+ if ((s->pps->transquant_bypass_enable_flag || -+ (s->sps->pcm.loop_filter_disable_flag && s->sps->pcm_enabled_flag)) && -+ s->sps->sao_enabled) -+ restore_tqb_pixels(s); -+ } - -- if (ctb_addr_ts < 0) { -- ret = ctb_addr_ts; -- goto fail; -- } -+ if (ctb_addr_ts < 0) { -+ ret = ctb_addr_ts; -+ goto fail; -+ } - } - break; - case NAL_EOS_NUT: -@@ -2942,16 +2942,16 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, - av_log(avctx, AV_LOG_ERROR, - "hardware accelerator failed to decode picture\n"); - } else { -- /* verify the SEI checksum */ -- if (avctx->err_recognition & AV_EF_CRCCHECK && s->is_decoded && -- s->is_md5) { -- ret = verify_md5(s, s->ref->frame); -- if (ret < 0 && avctx->err_recognition & AV_EF_EXPLODE) { -- ff_hevc_unref_frame(s, s->ref, ~0); -- return ret; -+ /* verify the SEI checksum */ -+ if (avctx->err_recognition & AV_EF_CRCCHECK && s->is_decoded && -+ s->is_md5) { -+ ret = verify_md5(s, s->ref->frame); -+ if (ret < 0 && avctx->err_recognition & AV_EF_EXPLODE) { -+ ff_hevc_unref_frame(s, s->ref, ~0); -+ return ret; -+ } - } - } -- } - s->is_md5 = 0; - - if (s->is_decoded) { -diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c -index 0b8e4ef..7508b0e 100644 ---- a/libavcodec/hevc_refs.c -+++ b/libavcodec/hevc_refs.c -@@ -356,18 +356,18 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) - return NULL; - - if (!s->avctx->hwaccel) { -- if (!s->sps->pixel_shift) { -- for (i = 0; frame->frame->buf[i]; i++) -- memset(frame->frame->buf[i]->data, 1 << (s->sps->bit_depth - 1), -- frame->frame->buf[i]->size); -- } else { -- for (i = 0; frame->frame->data[i]; i++) -- for (y = 0; y < (s->sps->height >> s->sps->vshift[i]); y++) -- for (x = 0; x < (s->sps->width >> s->sps->hshift[i]); x++) { -- AV_WN16(frame->frame->data[i] + y * frame->frame->linesize[i] + 2 * x, -- 1 << (s->sps->bit_depth - 1)); -- } -- } -+ if (!s->sps->pixel_shift) { -+ for (i = 0; frame->frame->buf[i]; i++) -+ memset(frame->frame->buf[i]->data, 1 << (s->sps->bit_depth - 1), -+ frame->frame->buf[i]->size); -+ } else { -+ for (i = 0; frame->frame->data[i]; i++) -+ for (y = 0; y < (s->sps->height >> s->sps->vshift[i]); y++) -+ for (x = 0; x < (s->sps->width >> s->sps->hshift[i]); x++) { -+ AV_WN16(frame->frame->data[i] + y * frame->frame->linesize[i] + 2 * x, -+ 1 << (s->sps->bit_depth - 1)); -+ } -+ } - } - - frame->poc = poc; --- -2.3.2 (Apple Git-55) - - -From 8de29b6b92e02b47cafe105f1b69d5648394e2a0 Mon Sep 17 00:00:00 2001 -From: Hendrik Leppkes <[email protected]> -Date: Sun, 25 Jan 2015 12:58:50 +0100 -Subject: [PATCH 8/9] Add DXVA2 HEVC HWAccel - -Signed-off-by: Anton Khirnov <[email protected]> -(cherry picked from commit 7e850fa67e32ebe98581c2e4ca4a4655dee7f116) ---- - configure | 5 + - libavcodec/Makefile | 1 + - libavcodec/allcodecs.c | 1 + - libavcodec/dxva2_hevc.c | 375 ++++++++++++++++++++++++++++++++++++++++++++++++ - libavcodec/hevc.c | 8 +- - 5 files changed, 389 insertions(+), 1 deletion(-) - create mode 100644 libavcodec/dxva2_hevc.c - -diff --git a/configure b/configure -index 33a7a85..4ea20c4 100755 ---- a/configure -+++ b/configure -@@ -1495,6 +1495,7 @@ TOOLCHAIN_FEATURES=" - " - - TYPES_LIST=" -+ DXVA_PicParams_HEVC - socklen_t - struct_addrinfo - struct_group_source_req -@@ -1938,6 +1939,8 @@ h264_vda_old_hwaccel_deps="vda" - h264_vda_old_hwaccel_select="h264_decoder" - h264_vdpau_hwaccel_deps="vdpau" - h264_vdpau_hwaccel_select="h264_decoder" -+hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" -+hevc_dxva2_hwaccel_select="hevc_decoder" - mpeg1_vdpau_hwaccel_deps="vdpau" - mpeg1_vdpau_hwaccel_select="mpeg1video_decoder" - mpeg2_dxva2_hwaccel_deps="dxva2" -@@ -4100,6 +4103,8 @@ check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi - - check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss - -+check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -+ - if ! disabled w32threads && ! enabled pthreads; then - check_func_headers "windows.h process.h" _beginthreadex && - enable w32threads || disable w32threads -diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index 752340f..7ea2018 100644 ---- a/libavcodec/Makefile -+++ b/libavcodec/Makefile -@@ -547,6 +547,7 @@ OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o - OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o - OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_h264.o - OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o -+OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o - OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL) += vdpau_mpeg12.o - OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o - OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o -diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c -index 6a71b2c..b7899ce 100644 ---- a/libavcodec/allcodecs.c -+++ b/libavcodec/allcodecs.c -@@ -81,6 +81,7 @@ void avcodec_register_all(void) - REGISTER_HWACCEL(H264_VDA, h264_vda); - REGISTER_HWACCEL(H264_VDA_OLD, h264_vda_old); - REGISTER_HWACCEL(H264_VDPAU, h264_vdpau); -+ REGISTER_HWACCEL(HEVC_DXVA2, hevc_dxva2); - REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau); - REGISTER_HWACCEL(MPEG2_DXVA2, mpeg2_dxva2); - REGISTER_HWACCEL(MPEG2_VAAPI, mpeg2_vaapi); -diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c -new file mode 100644 -index 0000000..2de9ef2 ---- /dev/null -+++ b/libavcodec/dxva2_hevc.c -@@ -0,0 +1,375 @@ -+/* -+ * DXVA2 HEVC HW acceleration. -+ * -+ * copyright (c) 2014 - 2015 Hendrik Leppkes -+ * -+ * 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 "libavutil/avassert.h" -+ -+#include "dxva2_internal.h" -+#include "hevc.h" -+ -+#define MAX_SLICES 256 -+ -+struct hevc_dxva2_picture_context { -+ DXVA_PicParams_HEVC pp; -+ DXVA_Qmatrix_HEVC qm; -+ unsigned slice_count; -+ DXVA_Slice_HEVC_Short slice_short[MAX_SLICES]; -+ const uint8_t *bitstream; -+ unsigned bitstream_size; -+}; -+ -+static void fill_picture_entry(DXVA_PicEntry_HEVC *pic, -+ unsigned index, unsigned flag) -+{ -+ av_assert0((index & 0x7f) == index && (flag & 0x01) == flag); -+ pic->bPicEntry = index | (flag << 7); -+} -+ -+static int get_refpic_index(const DXVA_PicParams_HEVC *pp, int surface_index) -+{ -+ int i; -+ for (i = 0; i < FF_ARRAY_ELEMS(pp->RefPicList); i++) { -+ if ((pp->RefPicList[i].bPicEntry & 0x7f) == surface_index) -+ return i; -+ } -+ return 0xff; -+} -+ -+static void fill_picture_parameters(struct dxva_context *ctx, const HEVCContext *h, -+ DXVA_PicParams_HEVC *pp) -+{ -+ const HEVCFrame *current_picture = h->ref; -+ int i, j, k; -+ -+ memset(pp, 0, sizeof(*pp)); -+ -+ pp->PicWidthInMinCbsY = h->sps->min_cb_width; -+ pp->PicHeightInMinCbsY = h->sps->min_cb_height; -+ -+ pp->wFormatAndSequenceInfoFlags = (h->sps->chroma_format_idc << 0) | -+ (h->sps->separate_colour_plane_flag << 2) | -+ ((h->sps->bit_depth - 8) << 3) | -+ ((h->sps->bit_depth - 8) << 6) | -+ ((h->sps->log2_max_poc_lsb - 4) << 9) | -+ (0 << 13) | -+ (0 << 14) | -+ (0 << 15); -+ -+ fill_picture_entry(&pp->CurrPic, ff_dxva2_get_surface_index(ctx, current_picture->frame), 0); -+ -+ pp->sps_max_dec_pic_buffering_minus1 = h->sps->temporal_layer[h->sps->max_sub_layers - 1].max_dec_pic_buffering - 1; -+ pp->log2_min_luma_coding_block_size_minus3 = h->sps->log2_min_cb_size - 3; -+ pp->log2_diff_max_min_luma_coding_block_size = h->sps->log2_diff_max_min_coding_block_size; -+ pp->log2_min_transform_block_size_minus2 = h->sps->log2_min_tb_size - 2; -+ pp->log2_diff_max_min_transform_block_size = h->sps->log2_max_trafo_size - h->sps->log2_min_tb_size; -+ pp->max_transform_hierarchy_depth_inter = h->sps->max_transform_hierarchy_depth_inter; -+ pp->max_transform_hierarchy_depth_intra = h->sps->max_transform_hierarchy_depth_intra; -+ pp->num_short_term_ref_pic_sets = h->sps->nb_st_rps; -+ pp->num_long_term_ref_pics_sps = h->sps->num_long_term_ref_pics_sps; -+ -+ pp->num_ref_idx_l0_default_active_minus1 = h->pps->num_ref_idx_l0_default_active - 1; -+ pp->num_ref_idx_l1_default_active_minus1 = h->pps->num_ref_idx_l1_default_active - 1; -+ pp->init_qp_minus26 = h->pps->pic_init_qp_minus26; -+ -+ if (h->sh.short_term_ref_pic_set_sps_flag == 0 && h->sh.short_term_rps) { -+ pp->ucNumDeltaPocsOfRefRpsIdx = h->sh.short_term_rps->num_delta_pocs; -+ pp->wNumBitsForShortTermRPSInSlice = h->sh.short_term_ref_pic_set_size; -+ } -+ -+ pp->dwCodingParamToolFlags = (h->sps->scaling_list_enable_flag << 0) | -+ (h->sps->amp_enabled_flag << 1) | -+ (h->sps->sao_enabled << 2) | -+ (h->sps->pcm_enabled_flag << 3) | -+ ((h->sps->pcm_enabled_flag ? (h->sps->pcm.bit_depth - 1) : 0) << 4) | -+ ((h->sps->pcm_enabled_flag ? (h->sps->pcm.bit_depth_chroma - 1) : 0) << 8) | -+ ((h->sps->pcm_enabled_flag ? (h->sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) | -+ ((h->sps->pcm_enabled_flag ? (h->sps->pcm.log2_max_pcm_cb_size - h->sps->pcm.log2_min_pcm_cb_size) : 0) << 14) | -+ (h->sps->pcm.loop_filter_disable_flag << 16) | -+ (h->sps->long_term_ref_pics_present_flag << 17) | -+ (h->sps->sps_temporal_mvp_enabled_flag << 18) | -+ (h->sps->sps_strong_intra_smoothing_enable_flag << 19) | -+ (h->pps->dependent_slice_segments_enabled_flag << 20) | -+ (h->pps->output_flag_present_flag << 21) | -+ (h->pps->num_extra_slice_header_bits << 22) | -+ (h->pps->sign_data_hiding_flag << 25) | -+ (h->pps->cabac_init_present_flag << 26) | -+ (0 << 27); -+ -+ pp->dwCodingSettingPicturePropertyFlags = (h->pps->constrained_intra_pred_flag << 0) | -+ (h->pps->transform_skip_enabled_flag << 1) | -+ (h->pps->cu_qp_delta_enabled_flag << 2) | -+ (h->pps->pic_slice_level_chroma_qp_offsets_present_flag << 3) | -+ (h->pps->weighted_pred_flag << 4) | -+ (h->pps->weighted_bipred_flag << 5) | -+ (h->pps->transquant_bypass_enable_flag << 6) | -+ (h->pps->tiles_enabled_flag << 7) | -+ (h->pps->entropy_coding_sync_enabled_flag << 8) | -+ (h->pps->uniform_spacing_flag << 9) | -+ ((h->pps->tiles_enabled_flag ? h->pps->loop_filter_across_tiles_enabled_flag : 0) << 10) | -+ (h->pps->seq_loop_filter_across_slices_enabled_flag << 11) | -+ (h->pps->deblocking_filter_override_enabled_flag << 12) | -+ (h->pps->disable_dbf << 13) | -+ (h->pps->lists_modification_present_flag << 14) | -+ (h->pps->slice_header_extension_present_flag << 15) | -+ (IS_IRAP(h) << 16) | -+ (IS_IDR(h) << 17) | -+ /* IntraPicFlag */ -+ (IS_IRAP(h) << 18) | -+ (0 << 19); -+ pp->pps_cb_qp_offset = h->pps->cb_qp_offset; -+ pp->pps_cr_qp_offset = h->pps->cr_qp_offset; -+ if (h->pps->tiles_enabled_flag) { -+ pp->num_tile_columns_minus1 = h->pps->num_tile_columns - 1; -+ pp->num_tile_rows_minus1 = h->pps->num_tile_rows - 1; -+ -+ if (!h->pps->uniform_spacing_flag) { -+ for (i = 0; i < h->pps->num_tile_columns; i++) -+ pp->column_width_minus1[i] = h->pps->column_width[i] - 1; -+ -+ for (i = 0; i < h->pps->num_tile_rows; i++) -+ pp->row_height_minus1[i] = h->pps->row_height[i] - 1; -+ } -+ } -+ -+ pp->diff_cu_qp_delta_depth = h->pps->diff_cu_qp_delta_depth; -+ pp->pps_beta_offset_div2 = h->pps->beta_offset / 2; -+ pp->pps_tc_offset_div2 = h->pps->tc_offset / 2; -+ pp->log2_parallel_merge_level_minus2 = h->pps->log2_parallel_merge_level - 2; -+ pp->CurrPicOrderCntVal = h->poc; -+ -+ // empty the lists -+ memset(&pp->RefPicList, 0xff, sizeof(pp->RefPicList)); -+ memset(&pp->RefPicSetStCurrBefore, 0xff, sizeof(pp->RefPicSetStCurrBefore)); -+ memset(&pp->RefPicSetStCurrAfter, 0xff, sizeof(pp->RefPicSetStCurrAfter)); -+ memset(&pp->RefPicSetLtCurr, 0xff, sizeof(pp->RefPicSetLtCurr)); -+ -+ // fill RefPicList from the DPB -+ for (i = 0, j = 0; i < FF_ARRAY_ELEMS(h->DPB); i++) { -+ const HEVCFrame *frame = &h->DPB[i]; -+ if (frame != current_picture && (frame->flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF))) { -+ fill_picture_entry(&pp->RefPicList[j], ff_dxva2_get_surface_index(ctx, frame->frame), !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF)); -+ pp->PicOrderCntValList[j] = frame->poc; -+ j++; -+ } -+ } -+ -+ #define DO_REF_LIST(ref_idx, ref_list) { \ -+ const RefPicList *rpl = &h->rps[ref_idx]; \ -+ av_assert0(rpl->nb_refs <= FF_ARRAY_ELEMS(pp->ref_list)); \ -+ for (j = 0, k = 0; j < rpl->nb_refs; j++) { \ -+ if (rpl->ref[j]) { \ -+ pp->ref_list[k] = get_refpic_index(pp, ff_dxva2_get_surface_index(ctx, rpl->ref[j]->frame)); \ -+ k++; \ -+ } \ -+ } \ -+ } -+ -+ // Fill short term and long term lists -+ DO_REF_LIST(ST_CURR_BEF, RefPicSetStCurrBefore); -+ DO_REF_LIST(ST_CURR_AFT, RefPicSetStCurrAfter); -+ DO_REF_LIST(LT_CURR, RefPicSetLtCurr); -+ -+ pp->StatusReportFeedbackNumber = 1 + ctx->report_id++; -+} -+ -+static void fill_scaling_lists(struct dxva_context *ctx, const HEVCContext *h, DXVA_Qmatrix_HEVC *qm) -+{ -+ unsigned i, j; -+ memset(qm, 0, sizeof(*qm)); -+ for (i = 0; i < 6; i++) { -+ for (j = 0; j < 16; j++) -+ qm->ucScalingLists0[i][j] = h->pps->scaling_list.sl[0][i][j]; -+ -+ for (j = 0; j < 64; j++) { -+ qm->ucScalingLists1[i][j] = h->pps->scaling_list.sl[1][i][j]; -+ qm->ucScalingLists2[i][j] = h->pps->scaling_list.sl[2][i][j]; -+ -+ if (i < 2) -+ qm->ucScalingLists3[i][j] = h->pps->scaling_list.sl[3][i][j]; -+ } -+ -+ qm->ucScalingListDCCoefSizeID2[i] = h->pps->scaling_list.sl_dc[0][i]; -+ if (i < 2) -+ qm->ucScalingListDCCoefSizeID3[i] = h->pps->scaling_list.sl_dc[1][i]; -+ } -+} -+ -+static void fill_slice_short(DXVA_Slice_HEVC_Short *slice, -+ unsigned position, unsigned size) -+{ -+ memset(slice, 0, sizeof(*slice)); -+ slice->BSNALunitDataLocation = position; -+ slice->SliceBytesInBuffer = size; -+ slice->wBadSliceChopping = 0; -+} -+ -+static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, -+ DXVA2_DecodeBufferDesc *bs, -+ DXVA2_DecodeBufferDesc *sc) -+{ -+ const HEVCContext *h = avctx->priv_data; -+ struct dxva_context *ctx = avctx->hwaccel_context; -+ const HEVCFrame *current_picture = h->ref; -+ struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; -+ DXVA_Slice_HEVC_Short *slice = NULL; -+ void *dxva_data_ptr; -+ uint8_t *dxva_data, *current, *end; -+ unsigned dxva_size; -+ void *slice_data; -+ unsigned slice_size; -+ unsigned padding; -+ unsigned i; -+ -+ /* Create an annex B bitstream buffer with only slice NAL and finalize slice */ -+ if (FAILED(IDirectXVideoDecoder_GetBuffer(ctx->decoder, -+ DXVA2_BitStreamDateBufferType, -+ &dxva_data_ptr, &dxva_size))) -+ return -1; -+ -+ dxva_data = dxva_data_ptr; -+ current = dxva_data; -+ end = dxva_data + dxva_size; -+ -+ for (i = 0; i < ctx_pic->slice_count; i++) { -+ static const uint8_t start_code[] = { 0, 0, 1 }; -+ static const unsigned start_code_size = sizeof(start_code); -+ unsigned position, size; -+ -+ slice = &ctx_pic->slice_short[i]; -+ -+ position = slice->BSNALunitDataLocation; -+ size = slice->SliceBytesInBuffer; -+ if (start_code_size + size > end - current) { -+ av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream"); -+ break; -+ } -+ -+ slice->BSNALunitDataLocation = current - dxva_data; -+ slice->SliceBytesInBuffer = start_code_size + size; -+ -+ memcpy(current, start_code, start_code_size); -+ current += start_code_size; -+ -+ memcpy(current, &ctx_pic->bitstream[position], size); -+ current += size; -+ } -+ padding = FFMIN(128 - ((current - dxva_data) & 127), end - current); -+ if (slice && padding > 0) { -+ memset(current, 0, padding); -+ current += padding; -+ -+ slice->SliceBytesInBuffer += padding; -+ } -+ if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(ctx->decoder, -+ DXVA2_BitStreamDateBufferType))) -+ return -1; -+ if (i < ctx_pic->slice_count) -+ return -1; -+ -+ memset(bs, 0, sizeof(*bs)); -+ bs->CompressedBufferType = DXVA2_BitStreamDateBufferType; -+ bs->DataSize = current - dxva_data; -+ bs->NumMBsInBuffer = 0; -+ -+ slice_data = ctx_pic->slice_short; -+ slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_short); -+ -+ av_assert0((bs->DataSize & 127) == 0); -+ return ff_dxva2_commit_buffer(avctx, ctx, sc, -+ DXVA2_SliceControlBufferType, -+ slice_data, slice_size, 0); -+} -+ -+ -+static int dxva2_hevc_start_frame(AVCodecContext *avctx, -+ av_unused const uint8_t *buffer, -+ av_unused uint32_t size) -+{ -+ const HEVCContext *h = avctx->priv_data; -+ struct dxva_context *ctx = avctx->hwaccel_context; -+ struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private; -+ -+ if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0) -+ return -1; -+ av_assert0(ctx_pic); -+ -+ /* Fill up DXVA_PicParams_HEVC */ -+ fill_picture_parameters(ctx, h, &ctx_pic->pp); -+ -+ /* Fill up DXVA_Qmatrix_HEVC */ -+ fill_scaling_lists(ctx, h, &ctx_pic->qm); -+ -+ ctx_pic->slice_count = 0; -+ ctx_pic->bitstream_size = 0; -+ ctx_pic->bitstream = NULL; -+ return 0; -+} -+ -+static int dxva2_hevc_decode_slice(AVCodecContext *avctx, -+ const uint8_t *buffer, -+ uint32_t size) -+{ -+ const HEVCContext *h = avctx->priv_data; -+ const HEVCFrame *current_picture = h->ref; -+ struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; -+ unsigned position; -+ -+ if (ctx_pic->slice_count >= MAX_SLICES) -+ return -1; -+ -+ if (!ctx_pic->bitstream) -+ ctx_pic->bitstream = buffer; -+ ctx_pic->bitstream_size += size; -+ -+ position = buffer - ctx_pic->bitstream; -+ fill_slice_short(&ctx_pic->slice_short[ctx_pic->slice_count], position, size); -+ ctx_pic->slice_count++; -+ -+ return 0; -+} -+ -+static int dxva2_hevc_end_frame(AVCodecContext *avctx) -+{ -+ HEVCContext *h = avctx->priv_data; -+ struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private; -+ int scale = ctx_pic->pp.dwCodingParamToolFlags & 1; -+ int ret; -+ -+ if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) -+ return -1; -+ -+ ret = ff_dxva2_common_end_frame(avctx, h->ref->frame, -+ &ctx_pic->pp, sizeof(ctx_pic->pp), -+ scale ? &ctx_pic->qm : NULL, scale ? sizeof(ctx_pic->qm) : 0, -+ commit_bitstream_and_slice_buffer); -+ return ret; -+} -+ -+AVHWAccel ff_hevc_dxva2_hwaccel = { -+ .name = "hevc_dxva2", -+ .type = AVMEDIA_TYPE_VIDEO, -+ .id = AV_CODEC_ID_HEVC, -+ .pix_fmt = AV_PIX_FMT_DXVA2_VLD, -+ .start_frame = dxva2_hevc_start_frame, -+ .decode_slice = dxva2_hevc_decode_slice, -+ .end_frame = dxva2_hevc_end_frame, -+ .frame_priv_data_size = sizeof(struct hevc_dxva2_picture_context), -+}; -diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c -index 81f0dc8..d43f7f5 100644 ---- a/libavcodec/hevc.c -+++ b/libavcodec/hevc.c -@@ -385,7 +385,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) - - static int set_sps(HEVCContext *s, const HEVCSPS *sps) - { -- #define HWACCEL_MAX (0) -+ #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL) - enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; - int ret; - unsigned int num = 0, den = 0; -@@ -401,6 +401,12 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps) - s->avctx->height = sps->output_height; - s->avctx->has_b_frames = sps->temporal_layer[sps->max_sub_layers - 1].num_reorder_pics; - -+ if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420P) { -+#if CONFIG_HEVC_DXVA2_HWACCEL -+ *fmt++ = AV_PIX_FMT_DXVA2_VLD; -+#endif -+ } -+ - *fmt++ = sps->pix_fmt; - *fmt = AV_PIX_FMT_NONE; - --- -2.3.2 (Apple Git-55) - - -From 3e8a77eee13d7446d9f7770176ad90b4f2ac2efd Mon Sep 17 00:00:00 2001 -From: Hendrik Leppkes <[email protected]> -Date: Tue, 3 Feb 2015 22:39:45 +0100 -Subject: [PATCH 9/9] dxva2_hevc: properly fill the scaling list structure - -The scaling list can be specified in either the SPS or PPS. -Additionally, compensate for the diagonal scan permutation applied -in the decoder. - -Signed-off-by: Luca Barbato <[email protected]> -(cherry picked from commit 8029af586fd5a5f2a0803001f9eff386e5545fe2) ---- - libavcodec/dxva2_hevc.c | 22 ++++++++++++++-------- - 1 file changed, 14 insertions(+), 8 deletions(-) - -diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c -index 2de9ef2..257bee7 100644 ---- a/libavcodec/dxva2_hevc.c -+++ b/libavcodec/dxva2_hevc.c -@@ -192,23 +192,29 @@ static void fill_picture_parameters(struct dxva_context *ctx, const HEVCContext - - static void fill_scaling_lists(struct dxva_context *ctx, const HEVCContext *h, DXVA_Qmatrix_HEVC *qm) - { -- unsigned i, j; -+ unsigned i, j, pos; -+ const ScalingList *sl = h->pps->scaling_list_data_present_flag ? -+ &h->pps->scaling_list : &h->sps->scaling_list; -+ - memset(qm, 0, sizeof(*qm)); - for (i = 0; i < 6; i++) { -- for (j = 0; j < 16; j++) -- qm->ucScalingLists0[i][j] = h->pps->scaling_list.sl[0][i][j]; -+ for (j = 0; j < 16; j++) { -+ pos = 4 * ff_hevc_diag_scan4x4_y[j] + ff_hevc_diag_scan4x4_x[j]; -+ qm->ucScalingLists0[i][j] = sl->sl[0][i][pos]; -+ } - - for (j = 0; j < 64; j++) { -- qm->ucScalingLists1[i][j] = h->pps->scaling_list.sl[1][i][j]; -- qm->ucScalingLists2[i][j] = h->pps->scaling_list.sl[2][i][j]; -+ pos = 8 * ff_hevc_diag_scan8x8_y[j] + ff_hevc_diag_scan8x8_x[j]; -+ qm->ucScalingLists1[i][j] = sl->sl[1][i][pos]; -+ qm->ucScalingLists2[i][j] = sl->sl[2][i][pos]; - - if (i < 2) -- qm->ucScalingLists3[i][j] = h->pps->scaling_list.sl[3][i][j]; -+ qm->ucScalingLists3[i][j] = sl->sl[3][i][pos]; - } - -- qm->ucScalingListDCCoefSizeID2[i] = h->pps->scaling_list.sl_dc[0][i]; -+ qm->ucScalingListDCCoefSizeID2[i] = sl->sl_dc[0][i]; - if (i < 2) -- qm->ucScalingListDCCoefSizeID3[i] = h->pps->scaling_list.sl_dc[1][i]; -+ qm->ucScalingListDCCoefSizeID3[i] = sl->sl_dc[1][i]; - } - } - --- -2.3.2 (Apple Git-55) - diff --git a/contrib/ffmpeg/A04-dxtory.patch b/contrib/ffmpeg/A04-dxtory.patch deleted file mode 100644 index c0929f67d..000000000 --- a/contrib/ffmpeg/A04-dxtory.patch +++ /dev/null @@ -1,685 +0,0 @@ -diff --git a/libavcodec/dxtory.c b/libavcodec/dxtory.c -index 23a3c6f..0a6f331 100644 ---- a/libavcodec/dxtory.c -+++ b/libavcodec/dxtory.c -@@ -192,6 +192,56 @@ static inline uint8_t decode_sym(GetBitContext *gb, uint8_t lru[8]) - return val; - } - -+static int check_slice_size(AVCodecContext *avctx, -+ const uint8_t *src, int src_size, -+ int slice_size, int off) -+{ -+ int cur_slice_size; -+ -+ if (slice_size > src_size - off) { -+ av_log(avctx, AV_LOG_ERROR, -+ "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n", -+ slice_size, src_size - off); -+ return AVERROR_INVALIDDATA; -+ } -+ if (slice_size <= 16) { -+ av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n", -+ slice_size); -+ return AVERROR_INVALIDDATA; -+ } -+ -+ cur_slice_size = AV_RL32(src + off); -+ if (cur_slice_size != slice_size - 16) { -+ av_log(avctx, AV_LOG_ERROR, -+ "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n", -+ cur_slice_size, slice_size - 16); -+ } -+ -+ return 0; -+} -+ -+static int load_buffer(AVCodecContext *avctx, -+ const uint8_t *src, int src_size, -+ GetByteContext *gb, -+ int *nslices, int *off) -+{ -+ bytestream2_init(gb, src, src_size); -+ *nslices = bytestream2_get_le16(gb); -+ *off = FFALIGN(*nslices * 4 + 2, 16); -+ if (src_size < *off) { -+ av_log(avctx, AV_LOG_ERROR, "no slice data\n"); -+ return AVERROR_INVALIDDATA; -+ } -+ -+ if (!*nslices) { -+ avpriv_request_sample(avctx, "%d slices for %dx%d", *nslices, -+ avctx->width, avctx->height); -+ return AVERROR_PATCHWELCOME; -+ } -+ -+ return 0; -+} -+ - static inline uint8_t decode_sym_565(GetBitContext *gb, uint8_t lru[8], - int bits) - { -@@ -210,185 +260,182 @@ static inline uint8_t decode_sym_565(GetBitContext *gb, uint8_t lru[8], - return val; - } - --static int dx2_decode_slice_565(GetBitContext *gb, int width, int height, -- uint8_t *dst, int stride, int is_565) --{ -- int x, y; -- int r, g, b; -- uint8_t lru[3][8]; -- -- memcpy(lru[0], def_lru_555, 8 * sizeof(*def_lru)); -- memcpy(lru[1], is_565 ? def_lru_565 : def_lru_555, 8 * sizeof(*def_lru)); -- memcpy(lru[2], def_lru_555, 8 * sizeof(*def_lru)); -- -- for (y = 0; y < height; y++) { -- for (x = 0; x < width; x++) { -- b = decode_sym_565(gb, lru[0], 5); -- g = decode_sym_565(gb, lru[1], is_565 ? 6 : 5); -- r = decode_sym_565(gb, lru[2], 5); -- dst[x * 3 + 0] = (r << 3) | (r >> 2); -- dst[x * 3 + 1] = is_565 ? (g << 2) | (g >> 4) : (g << 3) | (g >> 2); -- dst[x * 3 + 2] = (b << 3) | (b >> 2); -- } -- -- dst += stride; -- } -+typedef int (*decode_slice_func)(GetBitContext *gb, AVFrame *frame, -+ int line, int height, uint8_t lru[3][8]); - -- return 0; --} -+typedef void (*setup_lru_func)(uint8_t lru[3][8]); - --static int dxtory_decode_v2_565(AVCodecContext *avctx, AVFrame *pic, -- const uint8_t *src, int src_size, int is_565) -+static int dxtory_decode_v2(AVCodecContext *avctx, AVFrame *pic, -+ const uint8_t *src, int src_size, -+ decode_slice_func decode_slice, -+ setup_lru_func setup_lru, -+ enum AVPixelFormat fmt) - { - GetByteContext gb; - GetBitContext gb2; -- int nslices, slice, slice_height; -+ int nslices, slice, line = 0; - uint32_t off, slice_size; -- uint8_t *dst; -+ uint8_t lru[3][8]; - int ret; - -- bytestream2_init(&gb, src, src_size); -- nslices = bytestream2_get_le16(&gb); -- off = FFALIGN(nslices * 4 + 2, 16); -- if (src_size < off) { -- av_log(avctx, AV_LOG_ERROR, "no slice data\n"); -- return AVERROR_INVALIDDATA; -- } -- -- if (!nslices || avctx->height % nslices) { -- avpriv_request_sample(avctx, "%d slices for %dx%d", nslices, -- avctx->width, avctx->height); -- return AVERROR_PATCHWELCOME; -- } -+ ret = load_buffer(avctx, src, src_size, &gb, &nslices, &off); -+ if (ret < 0) -+ return ret; - -- slice_height = avctx->height / nslices; -- avctx->pix_fmt = AV_PIX_FMT_RGB24; -+ avctx->pix_fmt = fmt; - if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) - return ret; - -- dst = pic->data[0]; - for (slice = 0; slice < nslices; slice++) { - slice_size = bytestream2_get_le32(&gb); -- if (slice_size > src_size - off) { -- av_log(avctx, AV_LOG_ERROR, -- "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n", -- slice_size, src_size - off); -- return AVERROR_INVALIDDATA; -- } -- if (slice_size <= 16) { -- av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n", slice_size); -- return AVERROR_INVALIDDATA; -- } - -- if (AV_RL32(src + off) != slice_size - 16) { -- av_log(avctx, AV_LOG_ERROR, -- "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n", -- AV_RL32(src + off), slice_size - 16); -- } -+ setup_lru(lru); -+ -+ ret = check_slice_size(avctx, src, src_size, slice_size, off); -+ if (ret < 0) -+ return ret; -+ - init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8); -- dx2_decode_slice_565(&gb2, avctx->width, slice_height, dst, -- pic->linesize[0], is_565); - -- dst += pic->linesize[0] * slice_height; -+ line += decode_slice(&gb2, pic, line, avctx->height - line, lru); -+ - off += slice_size; - } - -+ if (avctx->height - line) { -+ av_log(avctx, AV_LOG_VERBOSE, -+ "Not enough slice data available, " -+ "cropping the frame by %d pixels\n", -+ avctx->height - line); -+ avctx->height = line; -+ } -+ - return 0; - } - --static int dx2_decode_slice_rgb(GetBitContext *gb, int width, int height, -- uint8_t *dst, int stride) -+av_always_inline -+static int dx2_decode_slice_5x5(GetBitContext *gb, AVFrame *frame, -+ int line, int left, uint8_t lru[3][8], -+ int is_565) - { -- int x, y, i; -- uint8_t lru[3][8]; -- -- for (i = 0; i < 3; i++) -- memcpy(lru[i], def_lru, 8 * sizeof(*def_lru)); -+ int x, y; -+ int r, g, b; -+ int width = frame->width; -+ int stride = frame->linesize[0]; -+ uint8_t *dst = frame->data[0] + stride * line; - -- for (y = 0; y < height; y++) { -+ for (y = 0; y < left && get_bits_left(gb) > 16; y++) { - for (x = 0; x < width; x++) { -- dst[x * 3 + 0] = decode_sym(gb, lru[0]); -- dst[x * 3 + 1] = decode_sym(gb, lru[1]); -- dst[x * 3 + 2] = decode_sym(gb, lru[2]); -+ b = decode_sym_565(gb, lru[0], 5); -+ g = decode_sym_565(gb, lru[1], is_565 ? 6 : 5); -+ r = decode_sym_565(gb, lru[2], 5); -+ dst[x * 3 + 0] = (r << 3) | (r >> 2); -+ dst[x * 3 + 1] = is_565 ? (g << 2) | (g >> 4) : (g << 3) | (g >> 2); -+ dst[x * 3 + 2] = (b << 3) | (b >> 2); - } - - dst += stride; - } - -- return 0; -+ return y; - } - --static int dxtory_decode_v2_rgb(AVCodecContext *avctx, AVFrame *pic, -- const uint8_t *src, int src_size) -+static void setup_lru_555(uint8_t lru[3][8]) - { -- GetByteContext gb; -- GetBitContext gb2; -- int nslices, slice, slice_height; -- uint32_t off, slice_size; -- uint8_t *dst; -- int ret; -+ memcpy(lru[0], def_lru_555, 8 * sizeof(*def_lru)); -+ memcpy(lru[1], def_lru_555, 8 * sizeof(*def_lru)); -+ memcpy(lru[2], def_lru_555, 8 * sizeof(*def_lru)); -+} - -- bytestream2_init(&gb, src, src_size); -- nslices = bytestream2_get_le16(&gb); -- off = FFALIGN(nslices * 4 + 2, 16); -- if (src_size < off) { -- av_log(avctx, AV_LOG_ERROR, "no slice data\n"); -- return AVERROR_INVALIDDATA; -- } -+static void setup_lru_565(uint8_t lru[3][8]) -+{ -+ memcpy(lru[0], def_lru_555, 8 * sizeof(*def_lru)); -+ memcpy(lru[1], def_lru_565, 8 * sizeof(*def_lru)); -+ memcpy(lru[2], def_lru_555, 8 * sizeof(*def_lru)); -+} - -- if (!nslices || avctx->height % nslices) { -- avpriv_request_sample(avctx, "%d slices for %dx%d", nslices, -- avctx->width, avctx->height); -- return AVERROR_PATCHWELCOME; -- } -+static int dx2_decode_slice_555(GetBitContext *gb, AVFrame *frame, -+ int line, int left, uint8_t lru[3][8]) -+{ -+ return dx2_decode_slice_5x5(gb, frame, line, left, lru, 0); -+} - -- slice_height = avctx->height / nslices; -- avctx->pix_fmt = AV_PIX_FMT_BGR24; -- if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) -- return ret; -+static int dx2_decode_slice_565(GetBitContext *gb, AVFrame *frame, -+ int line, int left, uint8_t lru[3][8]) -+{ -+ return dx2_decode_slice_5x5(gb, frame, line, left, lru, 1); -+} - -- dst = pic->data[0]; -- for (slice = 0; slice < nslices; slice++) { -- slice_size = bytestream2_get_le32(&gb); -- if (slice_size > src_size - off) { -- av_log(avctx, AV_LOG_ERROR, -- "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n", -- slice_size, src_size - off); -- return AVERROR_INVALIDDATA; -- } -- if (slice_size <= 16) { -- av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n", -- slice_size); -- return AVERROR_INVALIDDATA; -- } -+static int dxtory_decode_v2_565(AVCodecContext *avctx, AVFrame *pic, -+ const uint8_t *src, int src_size, int is_565) -+{ -+ enum AVPixelFormat fmt = AV_PIX_FMT_RGB24; -+ if (is_565) -+ return dxtory_decode_v2(avctx, pic, src, src_size, -+ dx2_decode_slice_565, -+ setup_lru_565, -+ fmt); -+ else -+ return dxtory_decode_v2(avctx, pic, src, src_size, -+ dx2_decode_slice_555, -+ setup_lru_555, -+ fmt); -+} -+ -+static int dx2_decode_slice_rgb(GetBitContext *gb, AVFrame *frame, -+ int line, int left, uint8_t lru[3][8]) -+{ -+ int x, y; -+ int width = frame->width; -+ int stride = frame->linesize[0]; -+ uint8_t *dst = frame->data[0] + stride * line; - -- if (AV_RL32(src + off) != slice_size - 16) { -- av_log(avctx, AV_LOG_ERROR, -- "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n", -- AV_RL32(src + off), slice_size - 16); -+ for (y = 0; y < left && get_bits_left(gb) > 16; y++) { -+ for (x = 0; x < width; x++) { -+ dst[x * 3 + 0] = decode_sym(gb, lru[0]); -+ dst[x * 3 + 1] = decode_sym(gb, lru[1]); -+ dst[x * 3 + 2] = decode_sym(gb, lru[2]); - } -- init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8); -- dx2_decode_slice_rgb(&gb2, avctx->width, slice_height, dst, -- pic->linesize[0]); - -- dst += pic->linesize[0] * slice_height; -- off += slice_size; -+ dst += stride; - } - -- return 0; -+ return y; - } - --static int dx2_decode_slice_410(GetBitContext *gb, int width, int height, -- uint8_t *Y, uint8_t *U, uint8_t *V, -- int ystride, int ustride, int vstride) -+static void default_setup_lru(uint8_t lru[3][8]) - { -- int x, y, i, j; -- uint8_t lru[3][8]; -+ int i; - - for (i = 0; i < 3; i++) - memcpy(lru[i], def_lru, 8 * sizeof(*def_lru)); -+} - -- for (y = 0; y < height; y += 4) { -+static int dxtory_decode_v2_rgb(AVCodecContext *avctx, AVFrame *pic, -+ const uint8_t *src, int src_size) -+{ -+ return dxtory_decode_v2(avctx, pic, src, src_size, -+ dx2_decode_slice_rgb, -+ default_setup_lru, -+ AV_PIX_FMT_BGR24); -+} -+ -+static int dx2_decode_slice_410(GetBitContext *gb, AVFrame *frame, -+ int line, int left, -+ uint8_t lru[3][8]) -+{ -+ int x, y, i, j; -+ int width = frame->width; -+ -+ int ystride = frame->linesize[0]; -+ int ustride = frame->linesize[1]; -+ int vstride = frame->linesize[2]; -+ -+ uint8_t *Y = frame->data[0] + ystride * line; -+ uint8_t *U = frame->data[1] + (ustride >> 2) * line; -+ uint8_t *V = frame->data[2] + (vstride >> 2) * line; -+ -+ for (y = 0; y < left - 3 && get_bits_left(gb) > 16; y += 4) { - for (x = 0; x < width; x += 4) { - for (j = 0; j < 4; j++) - for (i = 0; i < 4; i++) -@@ -402,96 +449,37 @@ static int dx2_decode_slice_410(GetBitContext *gb, int width, int height, - V += vstride; - } - -- return 0; -+ return y; - } - -+ - static int dxtory_decode_v2_410(AVCodecContext *avctx, AVFrame *pic, - const uint8_t *src, int src_size) - { -- GetByteContext gb; -- GetBitContext gb2; -- int nslices, slice, slice_height, ref_slice_height; -- int cur_y, next_y; -- uint32_t off, slice_size; -- uint8_t *Y, *U, *V; -- int ret; -- -- bytestream2_init(&gb, src, src_size); -- nslices = bytestream2_get_le16(&gb); -- off = FFALIGN(nslices * 4 + 2, 16); -- if (src_size < off) { -- av_log(avctx, AV_LOG_ERROR, "no slice data\n"); -- return AVERROR_INVALIDDATA; -- } -- -- if (!nslices || avctx->height % nslices) { -- avpriv_request_sample(avctx, "%d slices for %dx%d", nslices, -- avctx->width, avctx->height); -- return AVERROR_PATCHWELCOME; -- } -- -- ref_slice_height = avctx->height / nslices; -- if ((avctx->width & 3) || (avctx->height & 3)) { -- avpriv_request_sample(avctx, "Frame dimensions %dx%d", -- avctx->width, avctx->height); -- } -- -- avctx->pix_fmt = AV_PIX_FMT_YUV410P; -- if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) -- return ret; -- -- Y = pic->data[0]; -- U = pic->data[1]; -- V = pic->data[2]; -+ return dxtory_decode_v2(avctx, pic, src, src_size, -+ dx2_decode_slice_410, -+ default_setup_lru, -+ AV_PIX_FMT_YUV410P); -+} - -- cur_y = 0; -- next_y = ref_slice_height; -- for (slice = 0; slice < nslices; slice++) { -- slice_size = bytestream2_get_le32(&gb); -- slice_height = (next_y & ~3) - (cur_y & ~3); -- if (slice_size > src_size - off) { -- av_log(avctx, AV_LOG_ERROR, -- "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n", -- slice_size, src_size - off); -- return AVERROR_INVALIDDATA; -- } -- if (slice_size <= 16) { -- av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n", slice_size); -- return AVERROR_INVALIDDATA; -- } -+static int dx2_decode_slice_420(GetBitContext *gb, AVFrame *frame, -+ int line, int left, -+ uint8_t lru[3][8]) -+{ -+ int x, y; - -- if (AV_RL32(src + off) != slice_size - 16) { -- av_log(avctx, AV_LOG_ERROR, -- "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n", -- AV_RL32(src + off), slice_size - 16); -- } -- init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8); -- dx2_decode_slice_410(&gb2, avctx->width, slice_height, Y, U, V, -- pic->linesize[0], pic->linesize[1], -- pic->linesize[2]); -+ int width = frame->width; - -- Y += pic->linesize[0] * slice_height; -- U += pic->linesize[1] * (slice_height >> 2); -- V += pic->linesize[2] * (slice_height >> 2); -- off += slice_size; -- cur_y = next_y; -- next_y += ref_slice_height; -- } -+ int ystride = frame->linesize[0]; -+ int ustride = frame->linesize[1]; -+ int vstride = frame->linesize[2]; - -- return 0; --} -+ uint8_t *Y = frame->data[0] + ystride * line; -+ uint8_t *U = frame->data[1] + (ustride >> 1) * line; -+ uint8_t *V = frame->data[2] + (vstride >> 1) * line; - --static int dx2_decode_slice_420(GetBitContext *gb, int width, int height, -- uint8_t *Y, uint8_t *U, uint8_t *V, -- int ystride, int ustride, int vstride) --{ -- int x, y, i; -- uint8_t lru[3][8]; - -- for (i = 0; i < 3; i++) -- memcpy(lru[i], def_lru, 8 * sizeof(*def_lru)); -- -- for (y = 0; y < height; y+=2) { -+ for (y = 0; y < left - 1 && get_bits_left(gb) > 16; y += 2) { - for (x = 0; x < width; x += 2) { - Y[x + 0 + 0 * ystride] = decode_sym(gb, lru[0]); - Y[x + 1 + 0 * ystride] = decode_sym(gb, lru[0]); -@@ -506,96 +494,35 @@ static int dx2_decode_slice_420(GetBitContext *gb, int width, int height, - V += vstride; - } - -- return 0; -+ return y; - } - - static int dxtory_decode_v2_420(AVCodecContext *avctx, AVFrame *pic, - const uint8_t *src, int src_size) - { -- GetByteContext gb; -- GetBitContext gb2; -- int nslices, slice, slice_height, ref_slice_height; -- int cur_y, next_y; -- uint32_t off, slice_size; -- uint8_t *Y, *U, *V; -- int ret; -- -- bytestream2_init(&gb, src, src_size); -- nslices = bytestream2_get_le16(&gb); -- off = FFALIGN(nslices * 4 + 2, 16); -- if (src_size < off) { -- av_log(avctx, AV_LOG_ERROR, "no slice data\n"); -- return AVERROR_INVALIDDATA; -- } -- -- if (!nslices || avctx->height % nslices) { -- avpriv_request_sample(avctx, "%d slices for %dx%d", nslices, -- avctx->width, avctx->height); -- return AVERROR_PATCHWELCOME; -- } -- -- ref_slice_height = avctx->height / nslices; -- if ((avctx->width & 1) || (avctx->height & 1)) { -- avpriv_request_sample(avctx, "Frame dimensions %dx%d", -- avctx->width, avctx->height); -- } -- -- avctx->pix_fmt = AV_PIX_FMT_YUV420P; -- if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) -- return ret; -- -- Y = pic->data[0]; -- U = pic->data[1]; -- V = pic->data[2]; -- -- cur_y = 0; -- next_y = ref_slice_height; -- for (slice = 0; slice < nslices; slice++) { -- slice_size = bytestream2_get_le32(&gb); -- slice_height = (next_y & ~1) - (cur_y & ~1); -- if (slice_size > src_size - off) { -- av_log(avctx, AV_LOG_ERROR, -- "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n", -- slice_size, src_size - off); -- return AVERROR_INVALIDDATA; -- } -- if (slice_size <= 16) { -- av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n", slice_size); -- return AVERROR_INVALIDDATA; -- } -- -- if (AV_RL32(src + off) != slice_size - 16) { -- av_log(avctx, AV_LOG_ERROR, -- "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n", -- AV_RL32(src + off), slice_size - 16); -- } -- init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8); -- dx2_decode_slice_420(&gb2, avctx->width, slice_height, Y, U, V, -- pic->linesize[0], pic->linesize[1], -- pic->linesize[2]); -- -- Y += pic->linesize[0] * slice_height; -- U += pic->linesize[1] * (slice_height >> 1); -- V += pic->linesize[2] * (slice_height >> 1); -- off += slice_size; -- cur_y = next_y; -- next_y += ref_slice_height; -- } -- -- return 0; -+ return dxtory_decode_v2(avctx, pic, src, src_size, -+ dx2_decode_slice_420, -+ default_setup_lru, -+ AV_PIX_FMT_YUV420P); - } - --static int dx2_decode_slice_444(GetBitContext *gb, int width, int height, -- uint8_t *Y, uint8_t *U, uint8_t *V, -- int ystride, int ustride, int vstride) -+static int dx2_decode_slice_444(GetBitContext *gb, AVFrame *frame, -+ int line, int left, -+ uint8_t lru[3][8]) - { -- int x, y, i; -- uint8_t lru[3][8]; -+ int x, y; - -- for (i = 0; i < 3; i++) -- memcpy(lru[i], def_lru, 8 * sizeof(*def_lru)); -+ int width = frame->width; -+ -+ int ystride = frame->linesize[0]; -+ int ustride = frame->linesize[1]; -+ int vstride = frame->linesize[2]; -+ -+ uint8_t *Y = frame->data[0] + ystride * line; -+ uint8_t *U = frame->data[1] + ustride * line; -+ uint8_t *V = frame->data[2] + vstride * line; - -- for (y = 0; y < height; y++) { -+ for (y = 0; y < left && get_bits_left(gb) > 16; y++) { - for (x = 0; x < width; x++) { - Y[x] = decode_sym(gb, lru[0]); - U[x] = decode_sym(gb, lru[1]) ^ 0x80; -@@ -607,73 +534,16 @@ static int dx2_decode_slice_444(GetBitContext *gb, int width, int height, - V += vstride; - } - -- return 0; -+ return y; - } - - static int dxtory_decode_v2_444(AVCodecContext *avctx, AVFrame *pic, - const uint8_t *src, int src_size) - { -- GetByteContext gb; -- GetBitContext gb2; -- int nslices, slice, slice_height; -- uint32_t off, slice_size; -- uint8_t *Y, *U, *V; -- int ret; -- -- bytestream2_init(&gb, src, src_size); -- nslices = bytestream2_get_le16(&gb); -- off = FFALIGN(nslices * 4 + 2, 16); -- if (src_size < off) { -- av_log(avctx, AV_LOG_ERROR, "no slice data\n"); -- return AVERROR_INVALIDDATA; -- } -- -- if (!nslices || avctx->height % nslices) { -- avpriv_request_sample(avctx, "%d slices for %dx%d", nslices, -- avctx->width, avctx->height); -- return AVERROR_PATCHWELCOME; -- } -- -- slice_height = avctx->height / nslices; -- -- avctx->pix_fmt = AV_PIX_FMT_YUV444P; -- if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) -- return ret; -- -- Y = pic->data[0]; -- U = pic->data[1]; -- V = pic->data[2]; -- -- for (slice = 0; slice < nslices; slice++) { -- slice_size = bytestream2_get_le32(&gb); -- if (slice_size > src_size - off) { -- av_log(avctx, AV_LOG_ERROR, -- "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n", -- slice_size, src_size - off); -- return AVERROR_INVALIDDATA; -- } -- if (slice_size <= 16) { -- av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n", slice_size); -- return AVERROR_INVALIDDATA; -- } -- -- if (AV_RL32(src + off) != slice_size - 16) { -- av_log(avctx, AV_LOG_ERROR, -- "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n", -- AV_RL32(src + off), slice_size - 16); -- } -- init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8); -- dx2_decode_slice_444(&gb2, avctx->width, slice_height, Y, U, V, -- pic->linesize[0], pic->linesize[1], -- pic->linesize[2]); -- -- Y += pic->linesize[0] * slice_height; -- U += pic->linesize[1] * slice_height; -- V += pic->linesize[2] * slice_height; -- off += slice_size; -- } -- -- return 0; -+ return dxtory_decode_v2(avctx, pic, src, src_size, -+ dx2_decode_slice_444, -+ default_setup_lru, -+ AV_PIX_FMT_YUV444P); - } - - static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, diff --git a/contrib/ffmpeg/A05-matroskaenc-track-lang.patch b/contrib/ffmpeg/A05-matroskaenc-track-lang.patch deleted file mode 100644 index 4b16e4d41..000000000 --- a/contrib/ffmpeg/A05-matroskaenc-track-lang.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c -index b39d1b2..d65b6eb 100644 ---- a/libavformat/matroskaenc.c -+++ b/libavformat/matroskaenc.c -@@ -988,7 +988,9 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int eleme - - while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) - if (av_strcasecmp(t->key, "title") && -- av_strcasecmp(t->key, "encoding_tool")) -+ av_strcasecmp(t->key, "encoding_tool") && -+ (elementid != MATROSKA_ID_TAGTARGETS_TRACKUID || -+ av_strcasecmp(t->key, "language"))) - mkv_write_simpletag(s->pb, t); - - end_ebml_master(s->pb, tag); diff --git a/contrib/ffmpeg/A06-vc1-decode.patch b/contrib/ffmpeg/A06-vc1-decode.patch deleted file mode 100644 index e94993951..000000000 --- a/contrib/ffmpeg/A06-vc1-decode.patch +++ /dev/null @@ -1,28 +0,0 @@ -commit a97328afef0ccebfc8c3d9f9fdb8e93cbf1058ab -Author: Michael Niedermayer <[email protected]> -AuthorDate: Sun Sep 21 16:16:32 2014 +0100 -Commit: Tim Walker <[email protected]> -CommitDate: Fri Sep 26 16:55:36 2014 +0200 - - vc1: Use logical instead of bitwise or for twomv - - CC: [email protected] - Signed-off-by: Michael Niedermayer <[email protected]> - Signed-off-by: Tim Walker <[email protected]> - -diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c -index 35245ab..41beaeb 100644 ---- a/libavcodec/vc1dec.c -+++ b/libavcodec/vc1dec.c -@@ -4570,9 +4570,9 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) - if (mb_has_coeffs) - cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); - if (!direct) { -- if (bmvtype == (BMV_TYPE_INTERPOLATED & twomv)) { -+ if (bmvtype == BMV_TYPE_INTERPOLATED && twomv) { - v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1); -- } else if (bmvtype == (BMV_TYPE_INTERPOLATED | twomv)) { -+ } else if (bmvtype == BMV_TYPE_INTERPOLATED || twomv) { - v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1); - } - } diff --git a/contrib/ffmpeg/A08-mov-audio-fallback.patch b/contrib/ffmpeg/A08-mov-audio-fallback.patch deleted file mode 100644 index c8581aba6..000000000 --- a/contrib/ffmpeg/A08-mov-audio-fallback.patch +++ /dev/null @@ -1,119 +0,0 @@ -diff -ur libav-v11.3-0-g00abc00-orig/libavcodec/avcodec.h libav-v11.3-0-g00abc00/libavcodec/avcodec.h ---- libav-v11.3-0-g00abc00-orig/libavcodec/avcodec.h 2015-03-08 18:51:11.000000000 -0700 -+++ libav-v11.3-0-g00abc00/libavcodec/avcodec.h 2015-11-05 08:29:24.381723633 -0800 -@@ -917,6 +917,14 @@ - * Stereoscopic 3D information in form of the AVStereo3D struct. - */ - AV_PKT_DATA_STEREO3D, -+ -+ /** -+ * This side data contains an integer value representing the stream index -+ * of a "fallback" track. A fallback track indicates an alternate -+ * track to use when the current track can not be decoded for some reason. -+ * e.g. no decoder available for codec. -+ */ -+ AV_PKT_DATA_FALLBACK_TRACK, - }; - - typedef struct AVPacketSideData { -Only in libav-v11.3-0-g00abc00/libavcodec: avcodec.h.orig -diff -ur libav-v11.3-0-g00abc00-orig/libavformat/avformat.h libav-v11.3-0-g00abc00/libavformat/avformat.h ---- libav-v11.3-0-g00abc00-orig/libavformat/avformat.h 2015-03-08 18:51:11.000000000 -0700 -+++ libav-v11.3-0-g00abc00/libavformat/avformat.h 2015-11-05 08:28:54.944222066 -0800 -@@ -1361,6 +1361,16 @@ - AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c); - - /** -+ * Allocate new information from stream. -+ * -+ * @param stream stream -+ * @param type desired side information type -+ * @param size side information size -+ * @return pointer to fresh allocated data or NULL otherwise -+ */ -+uint8_t *av_stream_new_side_data(AVStream *stream, -+ enum AVPacketSideDataType type, int size); -+/** - * Get side information from stream. - * - * @param stream stream -Only in libav-v11.3-0-g00abc00/libavformat: avformat.h.orig -Only in libav-v11.3-0-g00abc00/libavformat: internal.h.orig -Only in libav-v11.3-0-g00abc00/libavformat: mov.c.orig -diff -ur libav-v11.3-0-g00abc00-orig/libavformat/movenc.c libav-v11.3-0-g00abc00/libavformat/movenc.c ---- libav-v11.3-0-g00abc00-orig/libavformat/movenc.c 2015-03-08 18:51:11.000000000 -0700 -+++ libav-v11.3-0-g00abc00/libavformat/movenc.c 2015-11-05 08:28:54.949222151 -0800 -@@ -2211,10 +2211,21 @@ - mov->tracks[i].tref_id = mov->tracks[mov->chapter_track].track_id; - } - for (i = 0; i < mov->nb_streams; i++) { -- if (mov->tracks[i].tag == MKTAG('r','t','p',' ')) { -- mov->tracks[i].tref_tag = MKTAG('h','i','n','t'); -- mov->tracks[i].tref_id = -- mov->tracks[mov->tracks[i].src_track].track_id; -+ MOVTrack *track = &mov->tracks[i]; -+ if (track->tag == MKTAG('r','t','p',' ')) { -+ track->tref_tag = MKTAG('h','i','n','t'); -+ track->tref_id = mov->tracks[track->src_track].track_id; -+ } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) { -+ int * fallback, size; -+ fallback = (int*)av_stream_get_side_data(track->st, -+ AV_PKT_DATA_FALLBACK_TRACK, -+ &size); -+ if (fallback != NULL && size == sizeof(int)) { -+ if (*fallback >= 0 && *fallback < mov->nb_streams) { -+ track->tref_tag = MKTAG('f','a','l','l'); -+ track->tref_id = mov->tracks[*fallback].track_id; -+ } -+ } - } - } - -Only in libav-v11.3-0-g00abc00/libavformat: movenc.c.orig -Only in libav-v11.3-0-g00abc00/libavformat: replaygain.c.orig -diff -ur libav-v11.3-0-g00abc00-orig/libavformat/utils.c libav-v11.3-0-g00abc00/libavformat/utils.c ---- libav-v11.3-0-g00abc00-orig/libavformat/utils.c 2015-03-08 18:51:11.000000000 -0700 -+++ libav-v11.3-0-g00abc00/libavformat/utils.c 2015-11-05 08:32:19.646709922 -0800 -@@ -3126,3 +3126,41 @@ - } - return NULL; - } -+ -+uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, -+ int size) -+{ -+ AVPacketSideData *sd, *tmp; -+ int i; -+ uint8_t *data = av_malloc(size); -+ -+ if (!data) -+ return NULL; -+ -+ for (i = 0; i < st->nb_side_data; i++) { -+ sd = &st->side_data[i]; -+ -+ if (sd->type == type) { -+ av_freep(&sd->data); -+ sd->data = data; -+ sd->size = size; -+ return sd->data; -+ } -+ } -+ -+ tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp)); -+ if (!tmp) { -+ av_freep(&data); -+ return NULL; -+ } -+ -+ st->side_data = tmp; -+ st->nb_side_data++; -+ -+ sd = &st->side_data[st->nb_side_data - 1]; -+ sd->type = type; -+ sd->data = data; -+ sd->size = size; -+ return data; -+} -+ -Only in libav-v11.3-0-g00abc00/libavformat: utils.c.orig diff --git a/contrib/ffmpeg/A09-atmos-substream.patch b/contrib/ffmpeg/A09-atmos-substream.patch deleted file mode 100644 index fd27fcf40..000000000 --- a/contrib/ffmpeg/A09-atmos-substream.patch +++ /dev/null @@ -1,181 +0,0 @@ -From d46e6f2723d51a9aa0c09e69bbc17ae71774b7c1 Mon Sep 17 00:00:00 2001 -From: Hendrik Leppkes <[email protected]> -Date: Fri, 26 Sep 2014 13:49:20 +0200 -Subject: [PATCH 1/2] mlpdec: support major sync headers with optional - extension blocks - -Signed-off-by: Anton Khirnov <[email protected]> -(cherry picked from commit f36f6a608b5b2c17f8876195c61621c8f8607cee) -Signed-off-by: Tim Walker <[email protected]> ---- - libavcodec/mlp_parser.c | 29 ++++++++++++++++++++++++----- - libavcodec/mlp_parser.h | 1 + - libavcodec/mlpdec.c | 7 ++++++- - 3 files changed, 31 insertions(+), 6 deletions(-) - -diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c -index 075227f..0c7d4a2 100644 ---- a/libavcodec/mlp_parser.c -+++ b/libavcodec/mlp_parser.c -@@ -119,6 +119,23 @@ static uint64_t truehd_layout(int chanmap) - return layout; - } - -+static int ff_mlp_get_major_sync_size(const uint8_t * buf, int bufsize) -+{ -+ int has_extension, extensions = 0; -+ int size = 28; -+ if (bufsize < 28) -+ return -1; -+ -+ if (AV_RB32(buf) == 0xf8726fba) { -+ has_extension = buf[25] & 1; -+ if (has_extension) { -+ extensions = buf[26] >> 4; -+ size += 2 + extensions * 2; -+ } -+ } -+ return size; -+} -+ - /** Read a major sync info header - contains high level information about - * the stream - sample rate, channel arrangement etc. Most of this - * information is not actually necessary for decoding, only for playback. -@@ -127,18 +144,19 @@ static uint64_t truehd_layout(int chanmap) - - int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb) - { -- int ratebits, channel_arrangement; -+ int ratebits, channel_arrangement, header_size; - uint16_t checksum; - - assert(get_bits_count(gb) == 0); - -- if (gb->size_in_bits < 28 << 3) { -+ header_size = ff_mlp_get_major_sync_size(gb->buffer, gb->size_in_bits >> 3); -+ if (header_size < 0 || gb->size_in_bits < header_size << 3) { - av_log(log, AV_LOG_ERROR, "packet too short, unable to read major sync\n"); - return -1; - } - -- checksum = ff_mlp_checksum16(gb->buffer, 26); -- if (checksum != AV_RL16(gb->buffer+26)) { -+ checksum = ff_mlp_checksum16(gb->buffer, header_size - 2); -+ if (checksum != AV_RL16(gb->buffer+header_size-2)) { - av_log(log, AV_LOG_ERROR, "major sync info header checksum error\n"); - return AVERROR_INVALIDDATA; - } -@@ -147,6 +165,7 @@ int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb) - return AVERROR_INVALIDDATA; - - mh->stream_type = get_bits(gb, 8); -+ mh->header_size = header_size; - - if (mh->stream_type == 0xbb) { - mh->group1_bits = mlp_quants[get_bits(gb, 4)]; -@@ -197,7 +216,7 @@ int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb) - - mh->num_substreams = get_bits(gb, 4); - -- skip_bits_long(gb, 4 + 11 * 8); -+ skip_bits_long(gb, 4 + (header_size - 17) * 8); - - return 0; - } -diff --git a/libavcodec/mlp_parser.h b/libavcodec/mlp_parser.h -index 7530fac..06ab421 100644 ---- a/libavcodec/mlp_parser.h -+++ b/libavcodec/mlp_parser.h -@@ -32,6 +32,7 @@ - typedef struct MLPHeaderInfo - { - int stream_type; ///< 0xBB for MLP, 0xBA for TrueHD -+ int header_size; ///< Size of the major sync header, in bytes - - int group1_bits; ///< The bit depth of the first substream - int group2_bits; ///< Bit depth of the second substream (MLP only) -diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c -index 6baf4c1..ad9e54f 100644 ---- a/libavcodec/mlpdec.c -+++ b/libavcodec/mlpdec.c -@@ -132,6 +132,9 @@ typedef struct MLPDecodeContext { - /// Current access unit being read has a major sync. - int is_major_sync_unit; - -+ /// Size of the major sync unit, in bytes -+ int major_sync_header_size; -+ - /// Set if a valid major sync block has been read. Otherwise no decoding is possible. - uint8_t params_valid; - -@@ -346,6 +349,8 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) - return AVERROR_PATCHWELCOME; - } - -+ m->major_sync_header_size = mh.header_size; -+ - m->access_unit_size = mh.access_unit_size; - m->access_unit_size_pow2 = mh.access_unit_size_pow2; - -@@ -1105,7 +1110,7 @@ static int read_access_unit(AVCodecContext *avctx, void* data, - if (read_major_sync(m, &gb) < 0) - goto error; - m->is_major_sync_unit = 1; -- header_size += 28; -+ header_size += m->major_sync_header_size; - } - - if (!m->params_valid) { --- -2.4.9 (Apple Git-60) - - -From 99d4726e198d321158139f327c9c21dec58bc376 Mon Sep 17 00:00:00 2001 -From: Hendrik Leppkes <[email protected]> -Date: Fri, 26 Sep 2014 13:49:21 +0200 -Subject: [PATCH 2/2] mlpdec: support TrueHD streams with an Atmos substream - -The fourth substream is being discarded, since its not raw audio data, -but an encoded Atmos stream which needs a specialized decoder. - -Fixes decoding of the true hd stream from Transformers\ -\ Age\ of\ Extinction\ 2014\ 1080P-003.mkv - -Signed-off-by: Anton Khirnov <[email protected]> -(cherry picked from commit dc2d0e06af459af9a7f91b65e0a3119acc4f1baa) -Signed-off-by: Tim Walker <[email protected]> ---- - libavcodec/mlp.h | 2 +- - libavcodec/mlpdec.c | 4 +++- - 2 files changed, 4 insertions(+), 2 deletions(-) - -diff --git a/libavcodec/mlp.h b/libavcodec/mlp.h -index 5a4ee5f..8a1584e 100644 ---- a/libavcodec/mlp.h -+++ b/libavcodec/mlp.h -@@ -45,7 +45,7 @@ - /** Maximum number of substreams that can be decoded. - * MLP's limit is 2. TrueHD supports at least up to 3. - */ --#define MAX_SUBSTREAMS 3 -+#define MAX_SUBSTREAMS 4 - - /** which multiple of 48000 the maximum sample rate is */ - #define MAX_RATEFACTOR 4 -diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c -index ad9e54f..5ace18d 100644 ---- a/libavcodec/mlpdec.c -+++ b/libavcodec/mlpdec.c -@@ -355,7 +355,9 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) - m->access_unit_size_pow2 = mh.access_unit_size_pow2; - - m->num_substreams = mh.num_substreams; -- m->max_decoded_substream = m->num_substreams - 1; -+ -+ /* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for non-audio data */ -+ m->max_decoded_substream = FFMIN(m->num_substreams - 1, 2); - - m->avctx->sample_rate = mh.group1_samplerate; - m->avctx->frame_size = mh.access_unit_size; --- -2.4.9 (Apple Git-60) - diff --git a/contrib/ffmpeg/A10-dcadec-false-overread.patch b/contrib/ffmpeg/A10-dcadec-false-overread.patch deleted file mode 100644 index 50ca00169..000000000 --- a/contrib/ffmpeg/A10-dcadec-false-overread.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c -index e988e94..a72195e 100644 ---- a/libavcodec/dcadec.c -+++ b/libavcodec/dcadec.c -@@ -1359,12 +1359,12 @@ static int dca_subframe_footer(DCAContext *s, int base_channel) - align_get_bits(&s->gb); // byte align - skip_bits(&s->gb, 16); // nAUXCRC16 - -- // additional data (reserved, cf. ETSI TS 102 114 V1.4.1) -- if ((reserved = (aux_data_end - get_bits_count(&s->gb))) < 0) { -- av_log(s->avctx, AV_LOG_ERROR, -- "Overread auxiliary data by %d bits\n", -reserved); -- return AVERROR_INVALIDDATA; -- } else if (reserved) { -+ /* -+ * additional data (reserved, cf. ETSI TS 102 114 V1.4.1) -+ * -+ * Note: don't check for overreads, aux_data_count can't be trusted. -+ */ -+ if ((reserved = (aux_data_end - get_bits_count(&s->gb))) > 0) { - avpriv_request_sample(s->avctx, - "Core auxiliary data reserved content"); - skip_bits_long(&s->gb, reserved); diff --git a/contrib/ffmpeg/A11-vf-pad.patch b/contrib/ffmpeg/A11-vf-pad.patch deleted file mode 100644 index 85115838f..000000000 --- a/contrib/ffmpeg/A11-vf-pad.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c -index 634af4c..cddd2a6 100644 ---- a/libavfilter/vf_pad.c -+++ b/libavfilter/vf_pad.c -@@ -167,12 +167,17 @@ static int config_input(AVFilterLink *inlink) - NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) - goto eval_fail; - s->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res; -+ if (!s->h) -+ var_values[VAR_OUT_H] = var_values[VAR_OH] = s->h = inlink->h; -+ - /* evaluate the width again, as it may depend on the evaluated output height */ - if ((ret = av_expr_parse_and_eval(&res, (expr = s->w_expr), - var_names, var_values, - NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) - goto eval_fail; - s->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res; -+ if (!s->w) -+ var_values[VAR_OUT_W] = var_values[VAR_OW] = s->w = inlink->w; - - /* evaluate x and y */ - av_expr_parse_and_eval(&res, (expr = s->x_expr), -@@ -197,11 +202,6 @@ static int config_input(AVFilterLink *inlink) - return AVERROR(EINVAL); - } - -- if (!s->w) -- s->w = inlink->w; -- if (!s->h) -- s->h = inlink->h; -- - s->w &= ~((1 << s->hsub) - 1); - s->h &= ~((1 << s->vsub) - 1); - s->x &= ~((1 << s->hsub) - 1); diff --git a/contrib/ffmpeg/A12-avfilter-framerate.patch b/contrib/ffmpeg/A12-avfilter-framerate.patch deleted file mode 100644 index 146e4fc3c..000000000 --- a/contrib/ffmpeg/A12-avfilter-framerate.patch +++ /dev/null @@ -1,352 +0,0 @@ -diff --git a/doc/filters.texi b/doc/filters.texi -index d9874b6..9804c0e 100644 ---- a/doc/filters.texi -+++ b/doc/filters.texi -@@ -209,6 +209,9 @@ The expression is evaluated through the eval API and can contain the following - constants: - - @table @option -+@item FRAME_RATE -+frame rate, only defined for constant frame-rate video -+ - @item PTS - the presentation timestamp in input - -diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c -index 64b2645..cd98d16 100644 ---- a/libavfilter/avfilter.c -+++ b/libavfilter/avfilter.c -@@ -195,6 +195,8 @@ int avfilter_config_links(AVFilterContext *filter) - link->src->inputs[0]->sample_aspect_ratio : (AVRational){1,1}; - - if (link->src->nb_inputs) { -+ if (!link->frame_rate.num && !link->frame_rate.den) -+ link->frame_rate = link->src->inputs[0]->frame_rate; - if (!link->w) - link->w = link->src->inputs[0]->w; - if (!link->h) -diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h -index 9dbfeea..0b670e0 100644 ---- a/libavfilter/avfilter.h -+++ b/libavfilter/avfilter.h -@@ -375,6 +375,18 @@ struct AVFilterLink { - AVLINK_STARTINIT, ///< started, but incomplete - AVLINK_INIT ///< complete - } init_state; -+ -+ /** -+ * Frame rate of the stream on the link, or 1/0 if unknown; -+ * if left to 0/0, will be automatically be copied from the first input -+ * of the source filter if it exists. -+ * -+ * Sources should set it to the best estimation of the real frame rate. -+ * Filters should update it if necessary depending on their function. -+ * Sinks can use it to set a default output frame rate. -+ * It is similar to the r_frae_rate field in AVStream. -+ */ -+ AVRational frame_rate; - }; - - /** -diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c -index a9b893c..ac14d54 100644 ---- a/libavfilter/buffersrc.c -+++ b/libavfilter/buffersrc.c -@@ -44,6 +44,7 @@ typedef struct BufferSourceContext { - const AVClass *class; - AVFifoBuffer *fifo; - AVRational time_base; ///< time_base to set in the output link -+ AVRational frame_rate; ///< frame_rate to set in the output link - - /* video only */ - int h, w; -@@ -191,6 +192,7 @@ static const AVOption video_options[] = { - #endif - { "sar", "sample aspect ratio", OFFSET(pixel_aspect), AV_OPT_TYPE_RATIONAL, { .dbl = 1 }, 0, DBL_MAX, V }, - { "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V }, -+ { "frame_rate", NULL, OFFSET(frame_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, INT_MAX, V }, - { NULL }, - }; - -@@ -308,6 +310,7 @@ static int config_props(AVFilterLink *link) - } - - link->time_base = c->time_base; -+ link->frame_rate = c->frame_rate; - return 0; - } - -diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c -index 98bafc2..ab3674a 100644 ---- a/libavfilter/setpts.c -+++ b/libavfilter/setpts.c -@@ -41,6 +41,7 @@ - - static const char *const var_names[] = { - "E", ///< Euler number -+ "FRAME_RATE", ///< defined only for constant frame-rate video - "INTERLACED", ///< tell if the current frame is interlaced - "N", ///< frame / sample number (starting at zero) - "PHI", ///< golden ratio -@@ -59,6 +60,7 @@ static const char *const var_names[] = { - - enum var_name { - VAR_E, -+ VAR_FRAME_RATE, - VAR_INTERLACED, - VAR_N, - VAR_PHI, -@@ -115,6 +117,10 @@ static int config_input(AVFilterLink *inlink) - setpts->var_values[VAR_SR] = inlink->sample_rate; - } - -+ setpts->var_values[VAR_FRAME_RATE] = inlink->frame_rate.num && -+ inlink->frame_rate.den ? -+ av_q2d(inlink->frame_rate) : NAN; -+ - av_log(inlink->src, AV_LOG_VERBOSE, "TB:%f\n", setpts->var_values[VAR_TB]); - return 0; - } -diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c -index ea22d37..e20f5a0 100644 ---- a/libavfilter/vf_fps.c -+++ b/libavfilter/vf_fps.c -@@ -117,6 +117,7 @@ static int config_props(AVFilterLink* link) - FPSContext *s = link->src->priv; - - link->time_base = (AVRational){ s->framerate.den, s->framerate.num }; -+ link->frame_rate= s->framerate; - link->w = link->src->inputs[0]->w; - link->h = link->src->inputs[0]->h; - -diff --git a/libavfilter/vf_framepack.c b/libavfilter/vf_framepack.c -index e9806ba..10c4add 100644 ---- a/libavfilter/vf_framepack.c -+++ b/libavfilter/vf_framepack.c -@@ -82,6 +82,7 @@ static int config_output(AVFilterLink *outlink) - int width = ctx->inputs[LEFT]->w; - int height = ctx->inputs[LEFT]->h; - AVRational time_base = ctx->inputs[LEFT]->time_base; -+ AVRational frame_rate = ctx->inputs[LEFT]->frame_rate; - - // check size and fps match on the other input - if (width != ctx->inputs[RIGHT]->w || -@@ -93,11 +94,18 @@ static int config_output(AVFilterLink *outlink) - return AVERROR_INVALIDDATA; - } else if (av_cmp_q(time_base, ctx->inputs[RIGHT]->time_base) != 0) { - av_log(ctx, AV_LOG_ERROR, -- "Left and right framerates differ (%d/%d vs %d/%d).\n", -+ "Left and right time bases differ (%d/%d vs %d/%d).\n", - time_base.num, time_base.den, - ctx->inputs[RIGHT]->time_base.num, - ctx->inputs[RIGHT]->time_base.den); - return AVERROR_INVALIDDATA; -+ } else if (av_cmp_q(frame_rate, ctx->inputs[RIGHT]->frame_rate) != 0) { -+ av_log(ctx, AV_LOG_ERROR, -+ "Left and right framerates differ (%d/%d vs %d/%d).\n", -+ frame_rate.num, frame_rate.den, -+ ctx->inputs[RIGHT]->frame_rate.num, -+ ctx->inputs[RIGHT]->frame_rate.den); -+ return AVERROR_INVALIDDATA; - } - - s->pix_desc = av_pix_fmt_desc_get(outlink->format); -@@ -108,6 +116,8 @@ static int config_output(AVFilterLink *outlink) - switch (s->format) { - case AV_STEREO3D_FRAMESEQUENCE: - time_base.den *= 2; -+ frame_rate.num *= 2; -+ - s->double_pts = AV_NOPTS_VALUE; - break; - case AV_STEREO3D_COLUMNS: -@@ -126,6 +136,7 @@ static int config_output(AVFilterLink *outlink) - outlink->w = width; - outlink->h = height; - outlink->time_base = time_base; -+ outlink->frame_rate= frame_rate; - - return 0; - } -diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c -index 0122b8d..04f74bc 100644 ---- a/libavfilter/vf_frei0r.c -+++ b/libavfilter/vf_frei0r.c -@@ -459,6 +459,7 @@ static int source_config_props(AVFilterLink *outlink) - outlink->w = s->w; - outlink->h = s->h; - outlink->time_base = s->time_base; -+ outlink->frame_rate = av_inv_q(s->time_base); - - if (s->destruct && s->instance) - s->destruct(s->instance); -diff --git a/libavfilter/vf_interlace.c b/libavfilter/vf_interlace.c -index 8ef58e4..939fabc 100644 ---- a/libavfilter/vf_interlace.c -+++ b/libavfilter/vf_interlace.c -@@ -109,8 +109,10 @@ static int config_out_props(AVFilterLink *outlink) - outlink->w = inlink->w; - outlink->h = inlink->h; - outlink->time_base = inlink->time_base; -+ outlink->frame_rate = inlink->frame_rate; - // half framerate - outlink->time_base.num *= 2; -+ outlink->frame_rate.den *= 2; - - - if (s->lowpass) { -diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c -index ede1765..9b60408 100644 ---- a/libavfilter/vf_showinfo.c -+++ b/libavfilter/vf_showinfo.c -@@ -140,12 +140,37 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) - return ff_filter_frame(inlink->dst->outputs[0], frame); - } - -+static int config_props(AVFilterContext *ctx, AVFilterLink *link, int is_out) -+{ -+ -+ av_log(ctx, AV_LOG_INFO, "config %s time_base: %d/%d, frame_rate: %d/%d\n", -+ is_out ? "out" :"in", -+ link->time_base.num, link->time_base.den, -+ link->frame_rate.num, link->frame_rate.den -+ ); -+ -+ return 0; -+} -+ -+static int config_props_in(AVFilterLink *link) -+{ -+ AVFilterContext *ctx = link->dst; -+ return config_props(ctx, link, 0); -+} -+ -+static int config_props_out(AVFilterLink *link) -+{ -+ AVFilterContext *ctx = link->src; -+ return config_props(ctx, link, 1); -+} -+ - static const AVFilterPad avfilter_vf_showinfo_inputs[] = { - { - .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer = ff_null_get_video_buffer, - .filter_frame = filter_frame, -+ .config_props = config_props_in, - }, - { NULL } - }; -@@ -153,7 +178,8 @@ static const AVFilterPad avfilter_vf_showinfo_inputs[] = { - static const AVFilterPad avfilter_vf_showinfo_outputs[] = { - { - .name = "default", -- .type = AVMEDIA_TYPE_VIDEO -+ .type = AVMEDIA_TYPE_VIDEO, -+ .config_props = config_props_out, - }, - { NULL } - }; -diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c -index 574eac4..62576f7 100644 ---- a/libavfilter/vf_yadif.c -+++ b/libavfilter/vf_yadif.c -@@ -462,6 +462,9 @@ static int config_props(AVFilterLink *link) - link->w = link->src->inputs[0]->w; - link->h = link->src->inputs[0]->h; - -+ if(s->mode&1) -+ link->frame_rate = av_mul_q(link->src->inputs[0]->frame_rate, (AVRational){2,1}); -+ - s->csp = av_pix_fmt_desc_get(link->format); - if (s->csp->comp[0].depth > 8) { - s->filter_line = filter_line_c_16bit; -diff --git a/libavfilter/vsrc_color.c b/libavfilter/vsrc_color.c -index 3b506ec..644fd8b 100644 ---- a/libavfilter/vsrc_color.c -+++ b/libavfilter/vsrc_color.c -@@ -138,6 +138,7 @@ static int color_config_props(AVFilterLink *inlink) - inlink->w = color->w; - inlink->h = color->h; - inlink->time_base = color->time_base; -+ inlink->frame_rate = av_inv_q(color->time_base); - - return 0; - } -diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c -index e41625e..b6be2ea 100644 ---- a/libavfilter/vsrc_testsrc.c -+++ b/libavfilter/vsrc_testsrc.c -@@ -46,10 +46,10 @@ typedef struct TestSourceContext { - const AVClass *class; - int h, w; - unsigned int nb_frame; -- AVRational time_base; -+ AVRational time_base, frame_rate; - int64_t pts, max_pts; - char *size; ///< video frame size -- char *rate; ///< video frame rate -+ char *frame_rate_str; ///< video frame rate - char *duration; ///< total duration of the generated video - AVRational sar; ///< sample aspect ratio - -@@ -65,8 +65,8 @@ typedef struct TestSourceContext { - static const AVOption testsrc_options[] = { - { "size", "set video size", OFFSET(size), AV_OPT_TYPE_STRING, {.str = "320x240"}, .flags = FLAGS }, - { "s", "set video size", OFFSET(size), AV_OPT_TYPE_STRING, {.str = "320x240"}, .flags = FLAGS }, -- { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, .flags = FLAGS }, -- { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, .flags = FLAGS }, -+ { "rate", "set video rate", OFFSET(frame_rate_str), AV_OPT_TYPE_STRING, {.str = "25"}, .flags = FLAGS }, -+ { "r", "set video rate", OFFSET(frame_rate_str), AV_OPT_TYPE_STRING, {.str = "25"}, .flags = FLAGS }, - { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = FLAGS }, - { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl = 1}, 0, INT_MAX, FLAGS }, - { NULL }, -@@ -75,7 +75,6 @@ static const AVOption testsrc_options[] = { - static av_cold int init_common(AVFilterContext *ctx) - { - TestSourceContext *test = ctx->priv; -- AVRational frame_rate_q; - int64_t duration = -1; - int ret = 0; - -@@ -84,9 +83,9 @@ static av_cold int init_common(AVFilterContext *ctx) - return ret; - } - -- if ((ret = av_parse_video_rate(&frame_rate_q, test->rate)) < 0 || -- frame_rate_q.den <= 0 || frame_rate_q.num <= 0) { -- av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", test->rate); -+ if ((ret = av_parse_video_rate(&test->frame_rate, test->frame_rate_str)) < 0 || -+ test->frame_rate.den <= 0 || test->frame_rate.num <= 0) { -+ av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", test->frame_rate_str); - return ret; - } - -@@ -95,15 +94,14 @@ static av_cold int init_common(AVFilterContext *ctx) - return ret; - } - -- test->time_base.num = frame_rate_q.den; -- test->time_base.den = frame_rate_q.num; -+ test->time_base = av_inv_q(test->frame_rate); - test->max_pts = duration >= 0 ? - av_rescale_q(duration, AV_TIME_BASE_Q, test->time_base) : -1; - test->nb_frame = 0; - test->pts = 0; - - av_log(ctx, AV_LOG_DEBUG, "size:%dx%d rate:%d/%d duration:%f sar:%d/%d\n", -- test->w, test->h, frame_rate_q.num, frame_rate_q.den, -+ test->w, test->h, test->frame_rate.num, test->frame_rate.den, - duration < 0 ? -1 : test->max_pts * av_q2d(test->time_base), - test->sar.num, test->sar.den); - return 0; -@@ -116,7 +114,8 @@ static int config_props(AVFilterLink *outlink) - outlink->w = test->w; - outlink->h = test->h; - outlink->sample_aspect_ratio = test->sar; -- outlink->time_base = test->time_base; -+ outlink->frame_rate = test->frame_rate; -+ outlink->time_base = test->time_base; - - return 0; - } diff --git a/contrib/ffmpeg/A13-avi-dv.patch b/contrib/ffmpeg/A13-avi-dv.patch deleted file mode 100644 index 1424fcc48..000000000 --- a/contrib/ffmpeg/A13-avi-dv.patch +++ /dev/null @@ -1,37 +0,0 @@ -commit 0fc61c6ab6912a2f0c40fdd3f3c591bc2a33efd4 -Author: Michael Niedermayer <[email protected]> -Date: Sat Nov 28 21:06:45 2015 +0100 - - avi: Validate the stream-id for DV as well - - Avoid false positives while syncing. - - Bug-Id: ffmpeg/4086 - Bug-Id: 879 - - Signed-off-by: Michael Niedermayer <[email protected]> - Signed-off-by: Luca Barbato <[email protected]> - -diff --git a/libavformat/avidec.c b/libavformat/avidec.c -index 43c178f..477e045 100644 ---- a/libavformat/avidec.c -+++ b/libavformat/avidec.c -@@ -995,7 +995,7 @@ start_sync: - goto start_sync; - } - -- n = avi->dv_demux ? 0 : get_stream_idx(d); -+ n = get_stream_idx(d); - - if (!((i - avi->last_pkt_pos) & 1) && - get_stream_idx(d + 1) < s->nb_streams) -@@ -1007,6 +1007,9 @@ start_sync: - goto start_sync; - } - -+ if (avi->dv_demux && n != 0) -+ continue; -+ - // parse ##dc/##wb - if (n < s->nb_streams) { - AVStream *st; diff --git a/contrib/ffmpeg/A14-eac3-request-sample.patch b/contrib/ffmpeg/A14-eac3-request-sample.patch deleted file mode 100644 index 537653315..000000000 --- a/contrib/ffmpeg/A14-eac3-request-sample.patch +++ /dev/null @@ -1,87 +0,0 @@ -From cce0074000cbcbe8f1fb3a9601cfb3ea0a50bc3f Mon Sep 17 00:00:00 2001 -From: Tim Walker <[email protected]> -Date: Fri, 1 Apr 2016 03:05:30 +0200 -Subject: [PATCH 1/2] eac3dec: don't call avpriv_request_sample every frame. - -These errors neither prevent nor stop successful decoding -of the E-AC-3 stream's "core", causing avpriv_request_sample -to be called for every single frame in the bitstream. ---- - libavcodec/ac3dec.h | 2 ++ - libavcodec/eac3dec.c | 10 ++++++++-- - 2 files changed, 10 insertions(+), 2 deletions(-) - -diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h -index babd0a7..2468f5a 100644 ---- a/libavcodec/ac3dec.h -+++ b/libavcodec/ac3dec.h -@@ -92,6 +92,8 @@ typedef struct AC3DecodeContext { - int lfe_mix_level_exists; ///< indicates if lfemixlevcod is specified (lfemixlevcode) - int lfe_mix_level; ///< LFE mix level index (lfemixlevcod) - int eac3; ///< indicates if current frame is E-AC-3 -+ int eac3_frame_dependent_found; ///< bitstream has E-AC-3 dependent frame(s) -+ int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s) - int dolby_surround_mode; ///< dolby surround mode (dsurmod) - int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod) - int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod) -diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c -index b9d079c..fe52d27 100644 ---- a/libavcodec/eac3dec.c -+++ b/libavcodec/eac3dec.c -@@ -300,7 +300,10 @@ int ff_eac3_parse_header(AC3DecodeContext *s) - application can select from. each independent stream can also contain - dependent streams which are used to add or replace channels. */ - if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) { -- avpriv_request_sample(s->avctx, "Dependent substream decoding"); -+ if (!s->eac3_frame_dependent_found) { -+ s->eac3_frame_dependent_found = 1; -+ avpriv_request_sample(s->avctx, "Dependent substream decoding"); -+ } - return AAC_AC3_PARSE_ERROR_FRAME_TYPE; - } else if (s->frame_type == EAC3_FRAME_TYPE_RESERVED) { - av_log(s->avctx, AV_LOG_ERROR, "Reserved frame type\n"); -@@ -312,7 +315,10 @@ int ff_eac3_parse_header(AC3DecodeContext *s) - associated to an independent stream have matching substream id's. */ - if (s->substreamid) { - /* only decode substream with id=0. skip any additional substreams. */ -- avpriv_request_sample(s->avctx, "Additional substreams"); -+ if (!s->eac3_subsbtreamid_found) { -+ s->eac3_subsbtreamid_found = 1; -+ avpriv_request_sample(s->avctx, "Additional substreams"); -+ } - return AAC_AC3_PARSE_ERROR_FRAME_TYPE; - } - --- -2.5.4 (Apple Git-61) - - -From bea249d14da03d249c78cb4dffc5d88121f3caa2 Mon Sep 17 00:00:00 2001 -From: Tim Walker <[email protected]> -Date: Fri, 1 Apr 2016 03:16:09 +0200 -Subject: [PATCH 2/2] ac3dec: change logging of skipped E-AC-3 substreams. - -Change log level from warning to debug: the E-AC-3 "core" -substream can be successfully decoded without the additional -and dependent substreams, and their presence is already -indicated via avpriv_request_sample in ff_eac3_parse_header. ---- - libavcodec/ac3dec.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c -index 4876ac0..02d02b2 100644 ---- a/libavcodec/ac3dec.c -+++ b/libavcodec/ac3dec.c -@@ -1355,7 +1355,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, - /* skip frame if CRC is ok. otherwise use error concealment. */ - /* TODO: add support for substreams and dependent frames */ - if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) { -- av_log(avctx, AV_LOG_WARNING, "unsupported frame type : " -+ av_log(avctx, AV_LOG_DEBUG, "unsupported frame type : " - "skipping frame\n"); - *got_frame_ptr = 0; - return buf_size; --- -2.5.4 (Apple Git-61) - diff --git a/contrib/ffmpeg/A15-vp9.patch b/contrib/ffmpeg/A15-vp9.patch deleted file mode 100644 index 77946b2b0..000000000 --- a/contrib/ffmpeg/A15-vp9.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff -ur libav-11.3.orig/libavcodec/libvpxenc.c libav-11.3/libavcodec/libvpxenc.c ---- libav-11.3.orig/libavcodec/libvpxenc.c 2015-03-08 19:54:09.000000000 -0600 -+++ libav-11.3/libavcodec/libvpxenc.c 2016-05-27 13:36:07.379025868 -0600 -@@ -70,9 +70,6 @@ - - /** String mappings for enum vp8e_enc_control_id */ - static const char *const ctlidstr[] = { -- [VP8E_UPD_ENTROPY] = "VP8E_UPD_ENTROPY", -- [VP8E_UPD_REFERENCE] = "VP8E_UPD_REFERENCE", -- [VP8E_USE_REFERENCE] = "VP8E_USE_REFERENCE", - [VP8E_SET_ROI_MAP] = "VP8E_SET_ROI_MAP", - [VP8E_SET_ACTIVEMAP] = "VP8E_SET_ACTIVEMAP", - [VP8E_SET_SCALEMODE] = "VP8E_SET_SCALEMODE", -@@ -345,8 +342,11 @@ - codecctl_int(avctx, VP8E_SET_ARNR_STRENGTH, ctx->arnr_strength); - if (ctx->arnr_type >= 0) - codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type); -- codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction); -- codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices)); -+ -+ if (CONFIG_LIBVPX_VP8_ENCODER && iface == &vpx_codec_vp8_cx_algo) { -+ codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction); -+ codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices)); -+ } - codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx->mb_threshold); - codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx->crf); - diff --git a/contrib/ffmpeg/module.defs b/contrib/ffmpeg/module.defs index 156c21524..296c1b542 100644 --- a/contrib/ffmpeg/module.defs +++ b/contrib/ffmpeg/module.defs @@ -9,13 +9,9 @@ endif $(eval $(call import.MODULE.defs,FFMPEG,ffmpeg,$(__deps__))) $(eval $(call import.CONTRIB.defs,FFMPEG)) -FFMPEG.FETCH.url = https://download.handbrake.fr/handbrake/contrib/libav-11.3.tar.gz -FFMPEG.FETCH.url += https://libav.org/releases/libav-11.3.tar.gz -FFMPEG.FETCH.sha256 = 5a6f6d5529d2074a5a9665bd3e048cbaefbfd88d57f0b59604baa0ce3602967e - -# TODO: libav >= 11.4 -#FFMPEG.FETCH.url = https://libav.org/releases/libav-11.4.tar.gz -#FFMPEG.FETCH.sha256 = 5a6f6d5529d2074a5a9665bd3e048cbaefbfd88d57f0b59604baa0ce3602967e +FFMPEG.FETCH.url = https://download.handbrake.fr/handbrake/contrib/libav-12.tar.gz +FFMPEG.FETCH.url += https://libav.org/releases/libav-12.tar.gz +FFMPEG.FETCH.sha256 = ca5cb22ba660f0bdc47817fdb9d99059a71f9eb0776c68cf8bef769a5ccc7534 FFMPEG.CONFIGURE.deps = FFMPEG.CONFIGURE.host = |