1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00
Commit Graph

151 Commits

Author SHA1 Message Date
Anton Khirnov
e7de05f98f h264dec: drop a redundant check
Cropping parameters are already checked for validity during SPS parsing,
no need to check them again.
2017-01-09 13:21:13 +01:00
Anton Khirnov
45286a625c h264dec: make sure to only end a field if it has been started
Calling ff_h264_field_end() when the per-field state is not properly
initialized leads to all kinds of undefined behaviour.

CC: libav-stable@libav.org
Bug-Id: 977 978 992
2016-12-19 08:15:58 +01:00
Derek Buitenhuis
5c7f2cf81d h264_slice: Wait for refs to be available before we use them in error concealment
This could happen when there was a frame number gap and frame threading was used.

Debugging-by: Ronald S. Bultje <rsbultje@gmail.com>
Debugging-by: Justin Ruggles <justin.ruggles@gmail.com>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>

CC:libav-stable@libav.org
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-12-14 10:38:15 +01:00
Anton Khirnov
4a9bab3db0 h264: fix decoding multiple fields per packet with slice threads
Since we only know whether a NAL unit corresponds to a new field after
parsing the slice header, this requires reorganizing the calls to slice
parsing, per-slice/field/frame init and actual decoding.

In the previous code, the function for slice header decoding also
immediately started a new field/frame as necessary, so any slices
already queued for decoding would no longer be decodable.

After this patch, we first parse the slice header, and if we determine
that a new field needs to be started we decode all the queued slices.
2016-07-15 15:33:54 +02:00
Anton Khirnov
f450cc7bc5 h264: eliminate decode_postinit()
This function's purpose is not very well defined. Currently it does two
(only marginally related) things: selecting the next output frame and
calling ff_thread_finish_setup() for frame threading. The first of those
more properly belongs under field_start(), while the second can be
called directly from decode_nal_units().
2016-07-15 15:33:28 +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
Diego Biurrun
3c84eaae9d h264: Eliminate unused but set variable
libavcodec/h264_slice.c:1384:9: warning: variable 'droppable' set but not used
2016-06-23 14:16:14 +02:00
Anton Khirnov
58640fe89e h264: handle frame recovery in h264_field_start()
This is a more appropriate place for this. H264Context.recovery_frame is
shared between frame threads, so modifying it where it is right now is
invalid.
2016-06-21 11:20:51 +02:00
Anton Khirnov
e26c64148b h264: discard slices of redundant pictures right after parsing the slice header
Going through the whole decoder initialization process for a slice we
are not going to decode is unnecessary and potentially dangerous.
2016-06-21 11:20:26 +02:00
Anton Khirnov
6efc463858 h264: always set redundant_pic_count during slice header parsing
It is always checked in the surrounding code, so this make sure we don't
see a value from an old slice.
2016-06-21 11:20:20 +02:00
Anton Khirnov
606fb6c032 h264: call the hwaccel frame_start() from h264_field_start()
This is a more appropriate place for it.
2016-06-21 11:19:51 +02:00
Anton Khirnov
d1d7678040 h264: fix the check for mixed IDR/non-IDR slices 2016-06-21 11:19:19 +02:00
Anton Khirnov
b13fc1e344 h264: do not pass H264Context to h264_slice_header_parse()
This should make it more clear that this function does not need any
decoder-global state other than the parameter sets.
2016-06-21 11:18:44 +02:00
Anton Khirnov
996f13413b h264: fix warnings in fill_filter_caches_inter()
The code does some weird casting to a 2-dimensional sub-array of
ref2frm. This is not necessary, since only one dimension is needed
there.
2016-06-21 11:18:15 +02:00
Anton Khirnov
bc7f426851 h264: drop tests whether the codec id is AV_CODEC_ID_H264
Those are unused remnants of the old SVQ3 code.
2016-06-21 11:17:59 +02:00
Anton Khirnov
5c2fb561d9 h264: add H264_ prefix to the NAL unit types
This will prevent conflicts e.g. in code that deals with both h264 and
hevc.
2016-06-21 11:17:28 +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
251cbb4400 h264: create a new header for common h264 definitions
Move the NAL unit types into it. This will allow to stop including the
whole decoder-specific h264dec.h in some code that is unrelated to the
decoder and only needs some enum values.
2016-06-21 11:12:41 +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 Khirnov
f651c6a259 h264: factor out setting frame properties / side data
Right now this code is mixed with selecting the next output frame. Move
it to a separate function called from h264_field_start(), which is a
more appropriate place for this.
2016-06-21 11:10:58 +02:00
Anton Khirnov
bcd91f1644 h264: move a per-field block from decode_slice_header() to field_start()
This is a more appropriate place for it.
2016-06-21 11:10:29 +02:00
Anton Khirnov
17e7c03e12 h264: only allow ending a field/starting a new one before finish_setup()
Doing this after ff_thread_finish_setup() is called is invalid and can
conflict with reads from the other thread.
2016-06-21 11:10:00 +02:00
Anton Khirnov
debca90863 h264: store {curr,max}_pic_num in the per-slice context
While the value of those variables will be constant for the whole frame,
they are only used in two functions called from slice header decoding.
Moving them to the per-slice context allows us to make the H264Context
passed to slice_header_parse() constant.
2016-06-21 11:09:21 +02:00
Anton Khirnov
f966498e43 h264: decode the poc values from the slice header into the per-slice context
Copy them into the decoder-global context in field_start(). This avoids
modifying the decoder-global context during bitstream parsing.
2016-06-21 11:08:56 +02:00
Anton Khirnov
54dd9b1cdd h264: set mb_aff_frame in frame_start()
Avoid unnecessary modification of the decoder-global state in per-slice
code.
2016-06-21 11:08:32 +02:00
Anton Khirnov
8d36932c8d h264: move the block starting a new field out of slice_header_parse()
There is no bitstream parsing in that block and messing with
decoder-global state is not something that belongs into header parsing.

Nothing else in this function depends on the value of current_slice,
except for two validity checks. Those checks are also moved out of
slice_header_parse().
2016-06-21 11:08:03 +02:00
Anton Khirnov
b25cd7540e h264: pass a H2645NAL to slice header decoding
Replace the decoder-global nal_unit_type/nal_ref_idc variables with the
per-NAL ones. The decoder-global ones still cannot be removed because
they are used by hwaccels.
2016-06-21 11:07:10 +02:00
Anton Khirnov
61f168ae34 h264: factor out setting the parameter sets for a frame 2016-06-12 20:27:53 +02:00
Anton Khirnov
6e92181bf8 h264: pass just the PPS to get_chroma_qp()
It does not need the whole context. This will simplify the following
commit.
2016-06-12 20:27:53 +02:00
Anton Khirnov
d1f539c97e h264: merge the two reinit blocks in slice_header_parse()
The only difference is that the first of them contains a
ff_h264_flush_change() call. While that is not necessary in the second
block, it should cause no problems either.

Reduce the verbosity of the reinit log message from info to verbose,
since now it will be displayed during every decode session.
2016-06-12 20:27:53 +02:00
Anton Khirnov
3fba16ecd9 h264: factor starting a new field out of parsing the slice header 2016-06-12 20:27:53 +02:00
Anton Khirnov
bec993381c h264: postpone generating the implicit MMCOs
Do it right before the MMCOs are applied to the DPB. This will allow
moving the frame_start() call out of the slice header parsing, since
generating the implicit MMCOs needs to be done after frame_start().
2016-06-12 20:27:53 +02:00
Anton Khirnov
2d410ebbaa h264: decode the MMCOs into per-slice contexts
They are stored in the slice header, so technically they are per-slice
(though they must be the same in every slice). This will simplify the
following commits.
2016-06-12 20:27:53 +02:00
Anton Khirnov
39ab2ea531 h264: rename mmco_index to nb_mmco
The variable stores the number of mmco entries, so the current name is
misleading.
2016-06-12 20:27:53 +02:00
Anton Khirnov
7ab5d577a9 h264: move initializing the slice start out of h264_slice_header_parse() 2016-06-12 20:27:53 +02:00
Anton Khirnov
4cec43a9ee h264: move calculating the POC out of h264_slice_header_parse()
This function does not do any bitstream parsing and it depends on the
current frame being allocated, so this will allow the frame_start() to
be moved out eventually.
2016-06-12 20:27:52 +02:00
Anton Khirnov
6dd996c7c8 h264: move building the reference list out of h264_slice_header_parse()
This does not do any bitstream parsing and will allow moving out other
code in later commits.
2016-06-12 20:27:52 +02:00
Anton Khirnov
0bad254300 h264: move initing the implicit pred weight table out of h264_slice_header_parse()
It depends on the reference list, so this will allow moving out the
reference list construction and consequently other code it depends on.
2016-06-12 20:27:52 +02:00
Anton Khirnov
ed9a20ebe4 h264: split reading the ref list modifications and actually building the ref list
This will allow postponing the reference list construction (and by
consequence some other functions, like frame_start) until the whole
slice header has been parsed.
2016-06-12 20:27:52 +02:00
Anton Khirnov
fa57059079 h264: move initialising the implicit pred weight table for MBAFF
Do it where the normal implicit table is initialised.
2016-06-12 20:27:52 +02:00
Anton Khirnov
7b50d60442 h264: call ff_h264_fill_mbaff_ref_list() when constructing the normal ref list
There is no real reason to call it separately.
2016-06-12 20:27:52 +02:00
Anton Khirnov
77a1e2c5f8 h264: move direct mode inits out of h264_slice_header_parse()
This code does not do any bitstream parsing, it just initializes some
internal state.
2016-06-12 20:27:52 +02:00
Anton Khirnov
d06e4d8aab h264: start splitting decode_slice_header()
That function is currently very long and entangles bitstream parsing and
decoder configuration. This makes the code much harder to read than
necessary.

Begin splitting the code that configures the decoder state based on the
slice header information from the parsing of the slice header.
2016-06-12 20:27:52 +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
2e5bde9565 h264: eliminate max_contexts
It is always equal to nb_slice_ctx.
2016-04-24 10:06:25 +02:00
Anton Khirnov
e065279529 h264: remove an artificial restriction on the number of slice threads
This limit is now unnecessary, we can easily support an arbitrary number
of threads.
2016-04-24 10:06:25 +02:00
Anton Khirnov
4fd34e639d h264: remove pointless setting of some variables in loop_filter
Those should already be set to the correct values.
2016-04-24 10:06:25 +02:00
Anton Khirnov
9c858ce33f h264: remove a pointless comment 2016-04-24 10:06:25 +02:00
Anton Khirnov
b77fffa127 h264: make slice threading work with deblocking_filter=1
In such a case, decode the MBs in parallel without the loop filter, then
execute the filter serially.

The ref2frm array was previously moved to H264SliceContext. That was
incorrect, since it applies to all the slices and should properly be in
H264Context (it did not actually break decoding, since this distinction
only becomes relevant with slice threading and deblocking_filter=1,
which was not implemented before this commit). The ref2frm array is thus
moved back to H264Context.
2016-04-24 10:06:25 +02:00
Anton Khirnov
370ddc7b38 h264: remove H264Context.pict_type
It is not used for anything internally, just exported in the output
frames. So remove the indirection and set it directly in frame_start().
2016-04-24 10:06:25 +02:00