ffmpeg: add upstream xvba patch

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2012-07-01 20:35:47 +02:00
parent dc72f56938
commit 43767b8a9e

View File

@ -0,0 +1,34 @@
From adc34a12c7d8b778021ae75562ccedd98a43a602 Mon Sep 17 00:00:00 2001
From: xbmc <fernetmenta@online.de>
Date: Thu, 28 Jun 2012 13:06:16 +0200
Subject: [PATCH] xvba: correct h.264 level in case it was encoded wrongly,
thanks @fritsch for pointing this out
---
lib/ffmpeg/libavcodec/xvba_h264.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libavcodec/xvba_h264.c b/libavcodec/xvba_h264.c
index 9be6ffb..a077442 100644
--- a/libavcodec/xvba_h264.c
+++ b/libavcodec/xvba_h264.c
@@ -102,6 +102,16 @@ static int end_frame(AVCodecContext *avctx)
pic_descriptor->avc_num_ref_frames = h->sps.ref_frame_count;
pic_descriptor->avc_reserved_8bit = 0;
+ /* Set correct level */
+ if (pic_descriptor->level == 41) {
+ const unsigned int mbw = pic_descriptor->width_in_mb;
+ const unsigned int mbh = pic_descriptor->height_in_mb;
+ const unsigned int max_ref_frames = 12288 * 1024 / (mbw * mbh * 384);
+ const unsigned int num_ref_frames = pic_descriptor->avc_num_ref_frames;
+ if (max_ref_frames < num_ref_frames)
+ pic_descriptor->level = 51;
+ }
+
pic_descriptor->avc_num_slice_groups_minus1 = h->pps.slice_group_count - 1;
pic_descriptor->avc_num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1;
pic_descriptor->avc_num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1;
--
1.7.10