aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2015-12-17 13:00:37 +0100
committerHendrik Leppkes <h.leppkes@gmail.com>2015-12-17 13:07:08 +0100
commit10e55bd658b06034d700553190b419b1af92b7cb (patch)
tree5386e0bb31dfdad09a9adb583dbb87368199552e
parentc6f1f334cbc50b1821b92afaee13abcd3502b34a (diff)
parentb09ad37c83841c399abb7f2503a2ab214d0c2d48 (diff)
downloadffmpeg-10e55bd658b06034d700553190b419b1af92b7cb.tar.gz
Merge commit 'b09ad37c83841c399abb7f2503a2ab214d0c2d48'
* commit 'b09ad37c83841c399abb7f2503a2ab214d0c2d48': h264: derive the delay from the level when it's not present Merged without changing the strict_std_compliance check, as it breaks FATE and changes decoding behavior. Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
-rw-r--r--libavcodec/h264.c15
-rw-r--r--libavcodec/h264_ps.c33
2 files changed, 37 insertions, 11 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 3d11328b2d..089a86fe42 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -906,18 +906,11 @@ static void decode_postinit(H264Context *h, int setup_finished)
// FIXME do something with unavailable reference frames
/* Sort B-frames into display order */
-
- if (h->sps.bitstream_restriction_flag &&
- h->avctx->has_b_frames < h->sps.num_reorder_frames) {
- h->avctx->has_b_frames = h->sps.num_reorder_frames;
- h->low_delay = 0;
- }
-
- if (h->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT &&
- !h->sps.bitstream_restriction_flag) {
- h->avctx->has_b_frames = MAX_DELAYED_PIC_COUNT - 1;
- h->low_delay = 0;
+ if (h->sps.bitstream_restriction_flag ||
+ h->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
+ h->avctx->has_b_frames = FFMAX(h->avctx->has_b_frames, h->sps.num_reorder_frames);
}
+ h->low_delay = !h->avctx->has_b_frames;
for (i = 0; 1; i++) {
if(i == MAX_DELAYED_PIC_COUNT || cur->poc < h->last_pocs[i]){
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index e37a6d62fa..0bca9c1a80 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -107,6 +107,26 @@ static const uint8_t default_scaling8[2][64] = {
24, 25, 27, 28, 30, 32, 33, 35 }
};
+/* maximum number of MBs in the DPB for a given level */
+static const int level_max_dpb_mbs[][2] = {
+ { 10, 396 },
+ { 11, 900 },
+ { 12, 2376 },
+ { 13, 2376 },
+ { 20, 2376 },
+ { 21, 4752 },
+ { 22, 8100 },
+ { 30, 8100 },
+ { 31, 18000 },
+ { 32, 20480 },
+ { 40, 32768 },
+ { 41, 32768 },
+ { 42, 34816 },
+ { 50, 110400 },
+ { 51, 184320 },
+ { 52, 184320 },
+};
+
static inline int decode_hrd_parameters(H264Context *h, SPS *sps)
{
int cpb_count, i;
@@ -535,6 +555,19 @@ int ff_h264_decode_seq_parameter_set(H264Context *h, int ignore_truncation)
goto fail;
}
+ /* if the maximum delay is not stored in the SPS, derive it based on the
+ * level */
+ if (!sps->bitstream_restriction_flag) {
+ sps->num_reorder_frames = MAX_DELAYED_PIC_COUNT - 1;
+ for (i = 0; i < FF_ARRAY_ELEMS(level_max_dpb_mbs); i++) {
+ if (level_max_dpb_mbs[i][0] == sps->level_idc) {
+ sps->num_reorder_frames = FFMIN(level_max_dpb_mbs[i][1] / (sps->mb_width * sps->mb_height),
+ sps->num_reorder_frames);
+ break;
+ }
+ }
+ }
+
if (!sps->sar.den)
sps->sar.den = 1;