Commit Graph

126 Commits

Author SHA1 Message Date
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
Anton Khirnov
56087ec0a2 h264: drop a pointless indirection 2016-04-24 10:06:25 +02:00
Anton Khirnov
99c554efc8 h264: eliminate low_delay
It is always unconditionally initialized in decode_postinit() and then
immediately used in one place further below. All the other places where
it is accessed are just useless fluff.
2016-04-24 10:06:24 +02:00
Anton Khirnov
89ae244e78 h264_refs: remove an unused parameter from ff_h264_fill_mbaff_ref_list() 2016-04-24 10:06:24 +02:00
Anton Khirnov
0ba471d7d8 h264: eliminate copy_fields
It is very fragile against fields being moved and hides what is actually
being copied. Copy all the fields explicitly instead.
2016-04-24 10:06:24 +02:00
Anton Khirnov
728d90a0c1 h264: decouple h264_sei from the h264 decoder
Make the SEI parsing independent of the H264Context, to allow
decoupling the parser from the decoder.
2016-04-24 10:06:24 +02:00
Anton Khirnov
c8dcff0cdb h264: factor out calculating the POC count into a separate file
This will allow decoupling the parser from the decoder.
2016-04-24 10:06:24 +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
a6e27f7add h264: factor out parsing the reference count into a separate file
This will allow decoupling the parser from the decoder.
2016-04-24 10:06:23 +02:00
Anton Khirnov
e9f884416c h264: move reading direct_spatial_mv_pred out of ff_set_ref_count()
It has nothing to do with the reference count and so does not belong in
this function.
2016-04-24 10:06:23 +02:00
Diego Biurrun
061dc20351 h264: Add missing ff_ prefix to internally visible h264_init_dequant_tables() 2016-03-30 17:19:13 +02:00
Anton Khirnov
ad9d3384de svq3: move the dequant buffer to SVQ3Context
Remove now unnecesary call to ff_h264_alloc_tables()
2016-03-28 09:56:09 +02:00
Anton Khirnov
e481458bc3 h264: factor out pred weight table parsing into a separate file
This will allow decoupling the parser from the decoder.
2016-03-28 09:48:31 +02:00
Diego Biurrun
a7da517f6a h264data: Move all data tables from a header to a .c file 2016-03-25 15:56:14 +01:00
Diego Biurrun
f4d581cda3 lavc: Deduplicate zigzag_scan table 2016-03-25 15:23:56 +01:00
Mark Thompson
d264c720f7 lavu: deprecate AV_PIX_FMT_VAAPI_*, replace with AV_PIX_FMT_VAAPI
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-03-19 15:40:22 +01:00
Diego Biurrun
29c2d06d67 cosmetics: Drop empty comment lines 2016-02-18 15:35:30 +01:00
Anton Khirnov
f1ccd07680 h264: do not call frame_start() for missing frames
We do not need to do a full setup like for a real frame, just allocate a
buffer and set cur_pic(_ptr).
2015-12-07 11:42:26 +01:00
Anton Khirnov
792b9c9dfc h264: set frame_num in start_frame(), not decode_slice_header()
That is a more appropriate place for it, since it is not allowed to
change between slices.
2015-12-06 09:43:45 +01:00
Anton Khirnov
741b494fa8 h264: eliminate default_ref_list
According to the spec, the reference list for a slice should be
constructed by first generating an initial (what we now call "default")
reference list and then optionally applying modifications to it.

Our code has an optimization where the initial reference list is
constructed for the first inter slice and then rebuilt for other slices
if needed. This, however, adds complexity to the code, requires an extra
2.5kB array in the codec context and there is no reason to think that it
has any positive effect on performance. Therefore, simplify the code by
generating the reference list from scratch for each slice.
2015-12-06 09:42:39 +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
3e3056f2a0 h264: Allow stream and container cropping at the same time
The container cropping is applied only when difference is within 16
pixels, and the smallest value between the two is chosen.

Bug-Id: 383
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-06-30 15:34:37 +02:00
Anton Khirnov
5ec0bdf2c5 h264: do not update the context fields copied between threads after finish_setup()
Should fix a large number of possible races with frame threading.
2015-06-27 16:48:48 +02:00
Anton Khirnov
e49e0f58e2 h264: make sure the slices do not overlap during slice threading
Based on a patch by Michael Niedermayer <michaelni@gmx.at>.
CC: libav-stable@libav.org
Found-by: Kieran Kunhya <kierank@obe.tv>
2015-06-27 16:43:22 +02:00
Andreas Cadhalpun
a4fbd55d6e h264: er: Copy from the previous reference only if compatible
Also use the frame pixel format instead of the one from the codec
context, which is more robust.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-06-15 13:39:07 +02:00
Michael Niedermayer
08d006f5a8 h264: Fix HWACCEL_MAX for D3D11
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-06-01 11:36:30 +03:00