Commit Graph

372 Commits

Author SHA1 Message Date
James Almer f41048f6ec Merge commit '5c2fb561d94fc51d76ab21d6f7cc5b6cc3aa599c'
* commit '5c2fb561d94fc51d76ab21d6f7cc5b6cc3aa599c':
  h264: add H264_ prefix to the NAL unit types

Conflicts:
libavcodec/h264_parse.c
libavcodec/h264_parser.c
libavcodec/h264_slice.c
libavcodec/h264dec.c

Merged-by: James Almer <jamrial@gmail.com>
2016-08-01 15:11:05 -03:00
James Almer 8c7932884d Merge commit 'f638b67e5790735f34620bf82025c9b9d6fc7216'
* commit 'f638b67e5790735f34620bf82025c9b9d6fc7216':
  h264: move the parameter set definitions to a new header file

Conflicts:
libavcodec/h264_parse.h
libavcodec/h264_ps.c
libavcodec/h264dec.h

Merged-by: James Almer <jamrial@gmail.com>
2016-08-01 12:58:09 -03:00
Clément Bœsch ecf65c30cf Merge commit '251cbb44003caf179fb17afbb8a6c56643c2a646'
* commit '251cbb44003caf179fb17afbb8a6c56643c2a646':
  h264: create a new header for common h264 definitions

Merged-by: Clément Bœsch <u@pkh.me>
2016-07-29 11:13:44 +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 19446dc5ff h264: drop unused NAL_FF_IGNORE 2016-06-21 11:10:46 +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 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 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 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 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 2e4a7bd553 h264: drop unused H264Context.gb
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-06-09 11:19:15 +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 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 0e7772c5e4 h264: remove unused H264SliceContext.rbsp_buffer 2016-04-24 10:06:25 +02:00
Anton Khirnov 7f045c4429 h264: merge ff_h264_free_context() into h264_decode_end()
It is no longer called from outside the h264 decoder.
2016-04-24 10:06:24 +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 755f79f84c h264_refs: make the H264Context const where possible 2016-04-24 10:06:24 +02:00
Anton Khirnov 72da8d9bb2 h264_parser: remove the remaining dependencies on the h264 decoder 2016-04-24 10:06:24 +02:00
Anton Khirnov 98c97994c5 h264: decouple extradata parsing from the decoder
This will allow decoupling the parser from the decoder.
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 8d0cc8ca97 h264_parser: switch to h2645_parse for NAL unescaping
Remove now unused ff_h264_decode_nal().
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 ca2f19b9cc h264: switch to h2645_parse for NAL parsing 2016-03-28 10:16:28 +02:00
Anton Khirnov add1467e5e svq3: drop the build dependency on the h264 decoder 2016-03-28 09:58:26 +02:00
Anton Khirnov ecc31f6b08 h264: move ff_h264_check_intra[4x4]_pred_mode() to h264_parse
It is shared with svq3.
2016-03-28 09:53:56 +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
Michael Niedermayer f435d081b0 h264: Add an AVClass pointer to H264Context
Sample-Id: asan_heap-uaf_3660f67_757_cov_1257014655_Hi422FR1_SONY_A.jsv
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-02-22 19:08:56 -05: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
Derek Buitenhuis d15368ee39 h264: Run VLC init under pthread_once
This makes the h.264 decoder threadsafe to initialize.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-10-14 14:35:34 +02:00
Kieran Kunhya b0017579b6 h264: Add support for Closed Caption export
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-17 01:44:22 +01:00
Vittorio Giovara 271ce76d31 h264: Parse registered data SEI message and AFD value
Partially based on code by Marton Balint and Kieran Kunhya.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-06-30 15:34:38 +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