Commit Graph

70 Commits

Author SHA1 Message Date
Vittorio Giovara
ff9db5cfd1 lavc: Use a stricter check for the color properties values
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-12-02 11:36:42 -05:00
Diego Biurrun
67deba8a41 Use avpriv_report_missing_feature() where appropriate 2016-11-08 17:54:34 +01:00
Diego Biurrun
b96f0ab3d2 h264: Kill broken disabled cruft 2016-08-17 12:16:42 +02:00
Anton Khirnov
a8cbe5a0cc h264_ps: export actual height in MBs as SPS.mb_height
Currently, SPS.mb_height is actually what the spec calls
PicHeightInMapUnits, which is half the frame height when interlacing is
allowed. Calling this 'mb_height' is quite confusing, and there are at
least two associated bugs where this field is treated as the actual
frame height - in the h264 parser and in the code computing maximum
reordering buffer size for a given level.

Fix those issues (and avoid possible future ones) by exporting the real
frame height in this field.
2016-07-11 16:29:57 +02:00
Anton Khirnov
70b1dcef2d h264: tighten the valid range for ref_frame_count
This field (which the spec calls max_num_ref_frames) must be less than
or equal to MaxDpbFrames, which is at most 16.
2016-06-21 11:14:07 +02:00
Anton Khirnov
f638b67e57 h264: move the parameter set definitions to a new header file
The PS parsing code is independent from the decoder, so it makes more
sense for it to have its own separate header.
2016-06-21 11:13:29 +02:00
Anton Khirnov
9df889a5f1 h264: rename h264.[ch] to h264dec.[ch]
This is more consistent with the naming of other decoders.
2016-06-21 11:11:26 +02:00
Anton Mitrofanov
a833ff68f6 h264: Fix decoding delay for Intra only streams
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-06-12 20:29:29 +02:00
Vittorio Giovara
41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
Anton Khirnov
3176217c60 h264: decouple h264_ps from the h264 decoder
Make the SPS/PPS parsing independent of the H264Context, to allow
decoupling the parser from the decoder. The change is modelled after the
one done earlier for HEVC.

Move the dequant buffers to the PPS to avoid complex checks whether they
changed and an expensive copy for frame threads.
2016-04-24 10:06:23 +02:00
Anton Khirnov
add1467e5e svq3: drop the build dependency on the h264 decoder 2016-03-28 09:58:26 +02:00
Diego Biurrun
f4d581cda3 lavc: Deduplicate zigzag_scan table 2016-03-25 15:23:56 +01:00
Anton Khirnov
b09ad37c83 h264: derive the delay from the level when it's not present
Fall back to maximum DPB size if the level is unknown.

This should be more spec-compliant and does not depend on the caller
setting has_b_frames before opening the decoder.

The old behaviour, when the delay is supplied by the caller setting
has_b_frames, can still be obtained by setting strict_std_compliance
below normal.
2015-12-06 09:43:52 +01:00
Vittorio Giovara
7c6eb0a1b7 lavc: AV-prefix all codec flags
Convert doxygen to multiline and express bitfields more simply.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:58 +01:00
Vittorio Giovara
86e1a35802 h264_ps: Return meaningful error codes and address a memory leak
Bug-Id: CID 1026763
2015-04-20 14:59:40 +01:00
Anton Khirnov
84f226a3bc h264: use the correct SPS during PPS parsing
There is in general no reason for the currently active SPS to be the one
referenced by the PPS being parsed.
2015-04-05 12:01:34 +02:00
Anton Khirnov
d8a45d2d49 h264_ps: properly check cropping parameters against overflow
CC: libav-stable@libav.org
2015-03-21 09:35:23 +01:00
Gabriel Dume
f929ab0569 cosmetics: Write NULL pointer equality checks more compactly
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2014-08-15 03:18:18 -07:00
Diego Biurrun
cba4e6062a More correct printf format specifiers
This avoids compiler warnings about argument and specifier type mismatch.
2014-04-02 00:27:22 +02:00
Diego Biurrun
cc8163e1a3 avcodec: more correct printf specifiers 2014-03-22 14:08:20 +01:00
Vittorio Giovara
5d1c2e53ab h264: Replace mpegvideo-specific MAX_PICTURE_COUNT by private define 2014-03-16 23:01:01 +01:00
Vittorio Giovara
ee6280ca12 h264: parse two additional constraint flags 2014-02-28 18:14:34 +01:00
Vittorio Giovara
e70ab7c1f5 h264: add MVCD to the list of High profiles in SPS
Also comment all previous profiles.
2014-02-28 18:14:33 +01:00
Vittorio Giovara
614b9e4db8 h264: use avpriv_request_sample for chroma_format_idc 2014-02-16 23:51:44 +01:00
Vittorio Giovara
3a05767028 h264: store current_sps_id inside the current sps
In preparation for MVC support.
2014-02-14 05:05:46 +01:00
Vittorio Giovara
73e8fab31d h264: print values in case of error
Also make error style consistent and drop redundant information.
2014-02-14 05:05:35 +01:00
Anton Khirnov
9ecabd7892 h264: reset num_reorder_frames if it is invalid
An invalid VUI is not considered a fatal error, so the SPS containing it
may still be used. Leaving an invalid value of num_reorder_frames there
can result in writing over the bounds of H264Context.delayed_pic.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC:libav-stable@libav.org
2014-01-18 20:53:06 +01:00
Anton Khirnov
bfd26b7ce6 h264: reject mismatching luma/chroma bit depths during sps parsing
There is no point in delaying the check and it avoids bugs with a
half-initialized context.

Fixes invalid reads.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC:libav-stable@libav.org
2014-01-06 08:23:45 +01:00
Anton Khirnov
94603feb1b h264_ps: when parsing a VUI fails, only abort when explode is set
A VUI doesn't contain anything strictly necessary for decoding.
Apparently there are many samples with truncated VUIs in the wild, this
commit should allow decoding them.
2013-10-27 21:39:01 +01:00
Diego Biurrun
c18838f5eb h264_ps: Use more meaningful error values 2013-08-20 21:24:42 +02:00
Diego Biurrun
330ad1f6a5 h264_ps: K&R formatting cosmetics 2013-08-20 21:23:24 +02:00
Diego Biurrun
8fed466b0a h264_ps: Drop commented-out cruft 2013-08-20 21:09:05 +02:00
Diego Biurrun
2a61592573 avcodec: Remove some commented-out debug cruft 2013-08-20 19:59:50 +02:00
Anton Khirnov
5e83d9aced h264: fully support cropping.
Based on a patch by Vittorio Giovara <vittorio.giovara@gmail.com>

Fixes Bug 378.
2013-04-19 09:28:08 +02:00
Diego Biurrun
c242bbd8b6 Remove unnecessary dsputil.h #includes 2013-02-26 00:51:34 +01:00
Anton Khirnov
2c54155407 h264: deMpegEncContextize
Most of the changes are just trivial are just trivial replacements of
fields from MpegEncContext with equivalent fields in H264Context.
Everything in h264* other than h264.c are those trivial changes.

The nontrivial parts are:
1) extracting a simplified version of the frame management code from
   mpegvideo.c. We don't need last/next_picture anymore, since h264 uses
   its own more complex system already and those were set only to appease
   the mpegvideo parts.
2) some tables that need to be allocated/freed in appropriate places.
3) hwaccels -- mostly trivial replacements.
   for dxva, the draw_horiz_band() call is moved from
   ff_dxva2_common_end_frame() to per-codec end_frame() callbacks,
   because it's now different for h264 and MpegEncContext-based
   decoders.
4) svq3 -- it does not use h264 complex reference system, so I just
   added some very simplistic frame management instead and dropped the
   use of ff_h264_frame_start(). Because of this I also had to move some
   initialization code to svq3.

Additional fixes for chroma format and bit depth changes by
Janne Grunau <janne-libav@jannau.net>

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2013-02-15 16:35:16 +01:00
Vittorio Giovara
a84fb6e06f h264: Allow discarding the cropping information from SPS
Some 3D systems overload the meaning of the field for other purposes.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-01-25 07:50:35 +01:00
Victor Lopez
1c8bf3bfed h264: fix sps parsing for SVC and CAVLC 4:4:4 Intra profiles
Fixes bug 396.

CC: libav-stable@libav.org
2012-12-19 13:40:48 +01:00
Janne Grunau
a421bbfe83 h264: fix memleak on error during SPS parsing
Introduced in d7d6efe42b.
2012-12-15 19:16:39 +01:00
Janne Grunau
072be3e896 h264: set parameters from SPS whenever it changes
Fixes a crash in the fuzzed sample sample_varPAR.avi_s26638 with
alternating bit depths.
2012-12-13 21:02:42 +01:00
Janne Grunau
d7d6efe42b h264: check sps.log2_max_frame_num for validity
Fixes infinite or long taking loop in frame num gap code in
the fuzzed sample bipbop234.ts_s223302.

CC: libav-stable@libav.org
2012-12-07 11:43:28 +01:00
Ronald S. Bultje
be391fb6df h264_ps: declare array of colorspace strings on its own line. 2012-07-29 14:53:42 -07:00
Ronald S. Bultje
732f9fcfe5 h264: additional protection against unsupported size/bitdepth changes.
Fixes crashes in codepaths not covered by original checks.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
2012-05-02 10:19:37 -07:00
Alexander Strange
cb34867780 h264: fix memleak in error path.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2012-03-24 15:34:33 -07:00
Alexander Strange
6ef4063957 h264: Add check for invalid chroma_format_idc
Fixes a crash when FF_DEBUG_PICT_INFO is used.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2012-03-24 15:29:38 -07:00
Michael Niedermayer
3aa661ec56 h264: improve parsing of broken AVC SPS
Parsing the entire NAL as SPS fixes decoding of some AVC bitstreams
with broken escaping. Since the size of the NAL unit is known and
checked against the buffer end we can parse it entirely without buffer
overreads.

Fixes playback of
http://streams.videolan.org/streams/mp4/Mr_MrsSmith-h264_aac.mp4

Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-03-13 00:31:52 +01:00
Alex Converse
3574a85ce5 Replace computations of remaining bits with calls to get_bits_left(). 2012-03-05 11:22:11 -08:00
Baptiste Coudurier
76741b0e56 h264: 4:2:2 intra decoding support
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-10-21 01:00:41 -07:00
Mans Rullgard
fdba370f8a h264: fix HRD parameters parsing
The bit_rate_value_minus1 and cpb_size_value_minus1 elements
allow a wider range than get_ue_golomb() supports.  This
adds a get_ue_golomb_long() function supporting up to 31
leading zeros, which is the maximum for these syntax
elements, and uses it in decode_hrd_parameters().

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-10-11 18:24:51 +01:00
Mans Rullgard
be1242a3f2 h264: fix detection of optional trailing PPS elements
The PPS may contain a few trailing elements whose presence is
only signalled by data remaining after the the mandatory part
has been parsed.  The current code fails to take into account
the rbsp_trailing_bits() when deciding whether to parse these
optional elements.  Assuming no unnecessary padding bytes are
passed to this function, the optional elements are present if
either more than 8 extra bits remain or the remaining bits do
not form a valid rbsp_trailing_bits() after the mandatory PPS
elements have been parsed.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-10-11 12:05:51 +01:00